public IEnumerator <List <object> > GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args)
        {
            Assert.IsNotNull(context);

            var gameObjectRunner = _prefabInstantiator.Instantiate(args);

            // First get instance
            bool hasMore = gameObjectRunner.MoveNext();

            var gameObject = gameObjectRunner.Current;

            // NOTE: Need to set includeInactive to true here, because prefabs are always
            // instantiated as disabled until injection occurs, so that Awake / OnEnabled is executed
            // after injection has occurred
            var allComponents = gameObject.GetComponentsInChildren(_componentType, true);

            Assert.That(allComponents.Length >= 1,
                        "Expected to find at least one component with type '{0}' on prefab '{1}'",
                        _componentType, _prefabInstantiator.GetPrefab().name);

            yield return(allComponents.Cast <object>().ToList());

            // Now do injection
            while (hasMore)
            {
                hasMore = gameObjectRunner.MoveNext();
            }
        }
Example #2
0
        public void GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args, out Action injectAction, List <object> buffer)
        {
            var instance = _prefabCreator.Instantiate(args, out injectAction);

            buffer.Add(instance);
        }
Example #3
0
        public List <object> GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args, out Action injectAction)
        {
            Assert.IsNotNull(context);

            var gameObject = _prefabInstantiator.Instantiate(args, out injectAction);

            // NOTE: Need to set includeInactive to true here, because prefabs are always
            // instantiated as disabled until injection occurs, so that Awake / OnEnabled is executed
            // after injection has occurred

            if (_matchSingle)
            {
                var match = gameObject.GetComponentInChildren(_componentType, true);

                Assert.IsNotNull(match, "Could not find component with type '{0}' on prefab '{1}'",
                                 _componentType, _prefabInstantiator.GetPrefab().name);

                return(new List <object>()
                {
                    match
                });
            }

            var allComponents = gameObject.GetComponentsInChildren(_componentType, true);

            Assert.That(allComponents.Length >= 1,
                        "Expected to find at least one component with type '{0}' on prefab '{1}'",
                        _componentType, _prefabInstantiator.GetPrefab().name);

            return(allComponents.Cast <object>().ToList());
        }
        public IEnumerator <GameObject> Instantiate(List <TypeValuePair> args)
        {
            // We can't really support arguments if we are using the cached value since
            // the arguments might change when called after the first time
            Assert.IsEmpty(args);

            if (_gameObject != null)
            {
                yield return(_gameObject);

                yield break;
            }

            var runner = _subInstantiator.Instantiate(new List <TypeValuePair>());

            // First get instance
            bool hasMore = runner.MoveNext();

            _gameObject = runner.Current;

            yield return(_gameObject);

            // Now do injection
            while (hasMore)
            {
                hasMore = runner.MoveNext();
            }
        }
        public IEnumerator <List <object> > GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args)
        {
            Assert.IsNotNull(context);

            var gameObjectRunner = _prefabInstantiator.Instantiate(args);

            // First get instance
            bool hasMore = gameObjectRunner.MoveNext();

            var gameObject = gameObjectRunner.Current;

            var allComponents = gameObject.GetComponentsInChildren(_componentType);

            Assert.That(allComponents.Length >= 1,
                        "Expected to find at least one component with type '{0}' on prefab '{1}'",
                        _componentType, _prefabInstantiator.GetPrefab().name);

            yield return(allComponents.Cast <object>().ToList());

            // Now do injection
            while (hasMore)
            {
                hasMore = gameObjectRunner.MoveNext();
            }
        }
        public List <object> GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args, out Action injectAction)
        {
            var instance = _prefabCreator.Instantiate(args, out injectAction);

            return(new List <object>()
            {
                instance
            });
        }
        public void GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args, out Action injectAction, List <object> buffer)
        {
            Assert.IsNotNull(context);

            var gameObject = _prefabInstantiator.Instantiate(context, args, out injectAction);

            var component = gameObject.AddComponent(_componentType);

            buffer.Add(component);
        }
        public List <object> GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args, out Action injectAction)
        {
            Assert.IsNotNull(context);

            UnityEngine.GameObject gameObject = _prefabInstantiator.Instantiate(args, out injectAction);

            UnityEngine.Component component = gameObject.AddComponent(_componentType);

            return(new List <object>()
            {
                component
            });
        }
Example #9
0
        public GameObject Instantiate(List <TypeValuePair> args, out Action injectAction)
        {
            // We can't really support arguments if we are using the cached value since
            // the arguments might change when called after the first time
            Assert.IsEmpty(args);

            if (_gameObject != null)
            {
                injectAction = null;
                return(_gameObject);
            }

            _gameObject = _subInstantiator.Instantiate(new List <TypeValuePair>(), out injectAction);
            return(_gameObject);
        }
Example #10
0
        public IEnumerator <List <object> > GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args)
        {
            var runner = _prefabCreator.Instantiate(args);

            // First get instance
            bool hasMore = runner.MoveNext();

            var instance = runner.Current;

            yield return(new List <object>()
            {
                instance
            });

            // Now do injection
            while (hasMore)
            {
                hasMore = runner.MoveNext();
            }
        }
        public IEnumerator <List <object> > GetAllInstancesWithInjectSplit(
            InjectContext context, List <TypeValuePair> args)
        {
            Assert.IsNotNull(context);

            var gameObjectRunner = _prefabInstantiator.Instantiate(args);

            // First get instance
            bool hasMore = gameObjectRunner.MoveNext();

            var gameObject = gameObjectRunner.Current;
            var component  = gameObject.AddComponent(_componentType);

            yield return(new List <object>()
            {
                component
            });

            // Now do injection
            while (hasMore)
            {
                hasMore = gameObjectRunner.MoveNext();
            }
        }