Zenject Global Bindings - unity3d

I'm well aware this might not be the best place to ask a Zenject question. I've already posted the same question on Zenject google groups page as well. I'm posting this here thinking that someone who is on here (who's not on google groups) might be able to help me out.
I have a question about Zenject Global Bindings.
My AR app at the moment have several different screens (saved as scenes). Each scene can be run on it's own that way I could keep it very compartmentalised. When I press a button on 'Screen1' it loads 'Screen2' so on and so forth. I'm using a very basic AppDelegate which contains a NavigationController class which handled all the UGUI transitions so that it appears as a normal iOS navigation based app so to speak. I'm injecting AppDelegate as Singleton on all the installers I have but since there are individual CompositionRoots for individual screens (scenes), globally they are not injected as singletons.
Is there a way to do this. Have a singleton injection all throughout the app but with different composition roots?
If not, how to use Global composition root?
I've followed instructions on the guide to create a global composition root and add the installer as a prefab and all that. I deleted installer from the scene as well. But when I play nothing happens. Am I missing something obvious here.
Thanks in advance.

in your Resources folder create a project context prefab
how to make a project context prefab.
You also absolutely have to include a "SceneContext" in your scene. this spawns the first "ProjectContext".
After the creation of said object, it will load on any scene start.
along with the installers and scriptable object installers provided on the prefab. along with bindings to singletons ie:
Container.Bind<IFoo>().To<Foo>().AsSingle().NonLazy();
this means, on zenject initilization you will have an instance of your singelton ready and waiting.

Related

SceneKit game architecture, communication between ViewControllers

I’m building a SceneKit game with three VC’s controlled by a NavigationController.
Trying to work out the best way to store the players details (settings and scores). The players details should be updatable by each VC.
I’ve implemented the MVC approach with a separate Model class to retrieve the data for the game.
There are:
MainViewController with character selection and links to other two screens ( + a link to a help screen)
GameViewController with SceneKit View and Scene and SpriteKit HUD overlay.
SettingsViewController with player results and settings.
I’m thinking of implementing a Player class to hold all the players details that should be accessible to each VC.
Should I pass updates to the players details via a delegate or update the destination VC when the VCs transition using a segue.
There’s partial answer here:
How to build a multilevel game in SceneKit
But I’m not sure if this is still the best way to do it.
Have researched this more and have a potential solution that might be useful for others.
This is based on Dependency Injection used to propagate state across View Controllers.
This is described well in the following two articles
Matteo Manferdini:
https://code.tutsplus.com/tutorials/the-right-way-to-share-state-between-swift-view-controllers--cms-28474
and Andy Obusek:
http://cleanswifter.com/dependency-injection-with-storyboards/
I haven't seen any posts on this... hope it helps in some small way.
I use a Data class (sharedInstance) and store my globals there. I use delegates to communicate between view controllers. Mostly, I just pass the game state or menu choices in delegates.
A lot depends on the complexity and of course I'm a purest when I can be, but in a real game (not example code), things can get pretty hairy. You are often dealing with many objects that need to talk to each other such as your players may need to talk with players and other objects. Loops, threading issues, sound engine, game state - there is a lot going on and it's pretty hard to do without a sharedInstance.
It's great if you can get the perfect design - hats off to those that do, but I try to get 80% with the design and use globals to solve one-off problems.

Unity3d + Facebook SDK - Switching Scenes

Before trying to do anything stupid I wanted to ask the experts: what are the best practices on the scenario of switching scenes?
Does Unity3D retain the information of FB.Login() on the first scene forever, or do I need to initialize FB on every scene I loaded?
Sorry to ask before testing it, I am away from my dev machine and really curious!
I made some research and found out that if we create a static class, with a static property it will remain the same as long as the game runs.
So I created 1 static class with a static property of my FacebookUser class and it remained active while switching scenes.

best way of dealing with layers of images / views for an iphone app

If i wanted to create a system whereby you could display a little rectangle ON TOP of an app already running, in which I could put any number of things, what would be the best, most apple standard way of doing it?
I'm thinking of something similar to iAdd. basically layers of views I suppose. I know that microsoft has a standard war of coding game menus for example. they're layered - each one has various event handlers for when things start and finish and they're own little update / load / draw methods etc that get called when appropriate. is there something similar for apps?
The most important thing really is just the starting point. what should I be doing in order to create another view over the existing one?
All UI elements in iOS inherit from class UIView. To add one view inside another use [view addSubview:subview]
For detailed information about how to use the UIView class, see View Programming Guide for iOS

Use multiple components in Flash AS3 - iPhone app

First of all: Happy new year!
I have a problem with Flash CS5.5, AS3. I have two ScrollPane Components in my document. They are both in another scene and the (instant)names are unique. But it isn’t working properly. When I go to the other scene with the second ScrollPane I get an error & it starts to flicker.
My error:
TypeError: Error #1006: setSize is not a function. at
application051_fla::MainTimeline/frame25()[application051_fla.MainTimeline::frame25:7]
I want to make an iPhone application and I want that multiple components working properly in one document.
My little piece of code (don’t think that the problem is in here):
ScrollPane02.source = tekst03;
ScrollPane02.setSize(350,400);
ScrollPane02.move(0, 20);
ScrollPane02.scrollDrag = false;
If you know the answer or what I am doing wrong, please comment! Searching for hours/days!
Thanks in advance!
Uploaded the .fla document. If you want to take a look at it (please), you can download it here: http://www.bregjebouwmans.nl/application061.fla
Edit:
Ok, after digging through the FLA, I finally figured out what you did . . . you right clicked on ScrollPane in the "Library", and clicked "Duplicate". Then you gave it the name ScrollPane02. Except that the duplication process did not connect the new object to the ScrollPane's setup. Instead, it created a generic MovieClip object. Since it is not an actual ScrollPane, it makes sense that all the methods on the timeline's Actionscript will fail.
This is why the solution (in the comments below) works. #AsTheWormTurns just used the first (actual) ScrollPane in two instances on the timeline; is a viable solution.
(The only caveat being that if you change the ScrollPane object in the Library, it will affect all instances. That shouldn't really be a problem, since -- for components -- you generally make changes only to instances.)
Useful tips from my initial answer:
When compiled into an SWF, scenes are just stuck one right after the other in the timeline, just like scenes in a movie. If you do not have a stop() at the end of one scene, it will continue to run right into the next scene, just like a movie. The idea of scenes is to separate content. This means that what exists in sceneA does not exist in sceneB. The scenes also have no access to each other.
My advice is to not use scenes at all. They are difficult to use correctly, and have very little use that is not better done using the timeline or Actionscript.

Exchange data between two iPhone child views

Been researching how to send data from one child view to another child view. The application has several views, where one is kind of real-time Settings view. Changes in settings should effect stuff inside other views.
NSUserDefaults seems to be popular, but I don't want persistent data nor automatic saving into database/file. Looks like potential slowdown, which I want to avoid.
Second popular thing is passing a reference to some common top level object into each child view. Just haven't found any tutorial, which would show me in detail how to do this... Most likely so easy, no tutorial is needed - after you figure it out once! Would appreciate, if you can point me to right direction (URL)!
Question: I'm thinking about using one "singleton object" to store "global data", access it from everywhere anytime. What could wrong with this? If I create it at e.g. appDelegate.m it should exist before anyone tries to access it, right?
I'm looking at this sample code.
I would recommend using delegates and/or notifications.
Instead of creating a new singleton in the app delegate, add the necessary data (or, even better, references to the data) in the app delegate and have the views have references to the app delegate.
You can also set up notifications so that your views can keep track of changes to the data that they display.
The beauty of a singleton is that it is automatically created when you first access it via some [singletonClass sharedInstance]. So you don't need to "create" it while launching. If it is global data that needs to be accessed from any view singleton might be the right way of doing this.