Ejemplo n.º 1
0
        public static void BindToObjectInScene <T>(
            this SceneView scene,
            string bindingName,
            bool rootContext)
        {
            var contextName = rootContext ? null : scene.ContextName;
            var obj         = string.IsNullOrEmpty(bindingName)
                ? scene.transform.FindChildRecursively <T>()
                : scene.transform.FindChildRecursively <T>(bindingName);

            if (obj == null)
            {
                throw new Exception(string.Format(
                                        "Failed to bind injection: Could not find <{0}> with name <{1}> in scene <{2}>.",
                                        typeof(T).Name, bindingName, scene.GetName()));
            }
            if (string.IsNullOrEmpty(bindingName))
            {
                Rapid.Bind <T>(obj, contextName);
            }
            else
            {
                Rapid.Bind(bindingName, obj, contextName);
            }
        }
Ejemplo n.º 2
0
        public static void BindToAddObjectToScene <TInterface, TImplementation>(
            this SceneView scene,
            string bindingName,
            bool rootContext)
            where TImplementation : Component, TInterface
        {
            var contextName = rootContext ? null : scene.ContextName;
            var obj         = scene.transform.AddChild <TImplementation>();

            if (!string.IsNullOrEmpty(bindingName))
            {
                obj.name = bindingName;
                Rapid.Bind(bindingName, obj, contextName);
            }
            else
            {
                Rapid.Bind <TInterface>(obj, contextName);
            }
        }
Ejemplo n.º 3
0
 public void UnregisterFromContext()
 {
     Rapid.UnregisterView(this);
 }
Ejemplo n.º 4
0
 public void RegisterWithContext()
 {
     Rapid.RegisterView(this);
 }
Ejemplo n.º 5
0
 public void RegisterWithContext()
 {
     _contextName = transform.FindFirstParent <SceneView>().ContextName;
     Rapid.RegisterView(this);
 }