Example #1
0
        /// <summary> 複数のインスタンスを生成. </summary>
        public IEnumerable <T> Instantiate <T>(int count, bool active = true, bool instantiateInWorldSpace = false) where T : Component
        {
            if (prefab == null)
            {
                PrefabErrorMessage();
                return(null);
            }

            var instances = UnityUtility.Instantiate <T>(parent, prefab, count, instantiateInWorldSpace).ToArray();

            instances.ForEach(x => UnityUtility.SetActive(x.gameObject, active));

            return(instances);
        }
Example #2
0
        //----- method -----

        public GameObject Instantiate(bool active = true, bool instantiateInWorldSpace = false)
        {
            if (prefab == null)
            {
                PrefabErrorMessage();
                return(null);
            }

            var instance = UnityUtility.Instantiate(parent, prefab, instantiateInWorldSpace);

            UnityUtility.SetActive(instance, active);

            return(instance);
        }
Example #3
0
        /// <summary> インスタンスを生成. </summary>
        public T Instantiate <T>(bool active = true, bool instantiateInWorldSpace = false) where T : Component
        {
            if (prefab == null)
            {
                PrefabErrorMessage();
                return(null);
            }

            var instance = UnityUtility.Instantiate <T>(parent, prefab, instantiateInWorldSpace);

            if (instance != null)
            {
                UnityUtility.SetActive(instance.gameObject, active);
            }

            return(instance);
        }