コード例 #1
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());
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
 public UnityEngine.Object GetPrefab()
 {
     return(_subInstantiator.GetPrefab());
 }
コード例 #5
0
 public GameObject GetPrefab()
 {
     return(_subInstantiator.GetPrefab());
 }
コード例 #6
0
 public UnityEngine.Object GetPrefab(InjectContext context)
 {
     return(_subInstantiator.GetPrefab(context));
 }