Beispiel #1
0
        //----- property -----

        //----- method -----

        void OnEnable()
        {
            instance = target as ParticlePlayer;

            if (!IsPrefabAssetInspector())
            {
                if (!instance.IsInitialized)
                {
                    Reflection.InvokePrivateMethod(instance, "Initialize");
                }

                if (!Application.isPlaying)
                {
                    ParticlePlayerEmulator.update -= Emulate;
                    ParticlePlayerEmulator.update += Emulate;

                    var colorCode = Color.magenta.ColorToHex();

                    eventLogDisposable = instance.OnEventAsObservable()
                                         .Subscribe(x => Debug.LogFormat("<color=#{0}><b>[ParticlePlayer Event]</b></color> {1}", colorCode, x))
                                         .AddTo(disposable.Disposable);
                }
                else
                {
                    updateDisposable = instance
                                       .ObserveEveryValueChanged(x => x.CurrentTime)
                                       .Subscribe(x => Repaint())
                                       .AddTo(disposable.Disposable);
                }
            }
        }
Beispiel #2
0
        //----- property -----

        //----- method -----

        void OnEnable()
        {
            instance = target as ParticlePlayer;

            if (!instance.IsInitialized)
            {
                Reflection.InvokePrivateMethod(instance, "Initialize");
            }

            if (applyDisposable != null)
            {
                applyDisposable.Dispose();
            }

            if (!Application.isPlaying)
            {
                ParticlePlayerEmulator.update -= Emulate;
                ParticlePlayerEmulator.update += Emulate;

                // Applyされたタイミングで子階層のSortingOrderを戻してから保存する.
                applyDisposable = PrefabApplyHook.OnApplyPrefabAsObservable().Subscribe(
                    x =>
                {
                    if (instance != null && x == instance.gameObject)
                    {
                        Reflection.InvokePrivateMethod(instance, "RevertOriginSortingOrder");
                    }
                })
                                  .AddTo(disposable.Disposable);
            }
            else
            {
                updateDisposable = instance
                                   .ObserveEveryValueChanged(x => x.CurrentTime)
                                   .Subscribe(x => Repaint())
                                   .AddTo(disposable.Disposable);
            }
        }