Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <summary> 複数のインスタンスを生成. </summary>
        public 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);

            if (instances != null)
            {
                instances.ForEach(x => UnityUtility.SetActive(x.gameObject, active));
            }

            return(instances);
        }
        /// <summary> 再生状態か取得. </summary>
        public static bool IsPlayback(this ParticleSystem particleSystem, bool subemitter = false)
        {
            // ※ ParticleSystem.IsAlive()は常にtrueを返すバグがあるので使わない.

            if (UnityUtility.IsNull(particleSystem))
            {
                return(false);
            }

            if (!UnityUtility.IsActiveInHierarchy(particleSystem))
            {
                return(false);
            }

            // ループエフェクトは常に生存.
            if (particleSystem.main.loop)
            {
                return(true);
            }

            // サブエミッターはtimeが更新されないので再生時間で判定しない.
            if (!subemitter)
            {
                // 再生時間より短いか.
                if (particleSystem.time < particleSystem.main.duration)
                {
                    return(true);
                }
            }

            // 1つでも生きてるParticleSystemがいたら生存中.
            if (0 < particleSystem.particleCount)
            {
                return(true);
            }

            return(false);
        }
        public static IObservable <Unit> OnCancelAsObservable(this Button button)
        {
            var trigger = UnityUtility.GetOrAddComponent <ButtonEventTrigger>(button.gameObject);

            return(trigger.OnCancelAsObservable());
        }
        public static IObservable <float> OnLongPressReleaseAsObservable(this Button button)
        {
            var trigger = UnityUtility.GetOrAddComponent <ButtonEventTrigger>(button.gameObject);

            return(trigger.OnLongPressReleaseAsObservable());
        }
        public static void SetLongPressDuration(this Button button, float duration)
        {
            var trigger = UnityUtility.GetOrAddComponent <ButtonEventTrigger>(button.gameObject);

            trigger.SetLongPressDuration(duration);
        }