public static void AddOnDisableBehaviour(this GameObject caller, UnityAction action)
    {
        OnDisableBehaviour onDisable = caller.GetOrAddComponent <OnDisableBehaviour>();

        onDisable.Disabled = new UnityEvent();
        onDisable.Disabled.AddListener(action);
    }
        public override void OnInspectorGUI()
        {
            EditorGUIUtils.SetGUIStyles(null);
            EditorGUIUtility.labelWidth = 80f;
            EditorGUIUtils.InspectorLogo();
            VisualManagerPreset preset = this._src.preset;

            this._src.preset = (VisualManagerPreset)EditorGUILayout.EnumPopup("Preset", this._src.preset, new GUILayoutOption[0]);
            if ((preset != this._src.preset) && (this._src.preset == VisualManagerPreset.PoolingSystem))
            {
                this._src.onEnableBehaviour  = OnEnableBehaviour.RestartFromSpawnPoint;
                this._src.onDisableBehaviour = OnDisableBehaviour.Rewind;
            }
            GUILayout.Space(6f);
            bool flag = this._src.preset > VisualManagerPreset.Custom;
            OnEnableBehaviour  onEnableBehaviour  = this._src.onEnableBehaviour;
            OnDisableBehaviour onDisableBehaviour = this._src.onDisableBehaviour;

            this._src.onEnableBehaviour  = (OnEnableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Enable", "Eventual actions to perform when this gameObject is activated"), this._src.onEnableBehaviour, new GUILayoutOption[0]);
            this._src.onDisableBehaviour = (OnDisableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Disable", "Eventual actions to perform when this gameObject is deactivated"), this._src.onDisableBehaviour, new GUILayoutOption[0]);
            if ((flag && (onEnableBehaviour != this._src.onEnableBehaviour)) || (onDisableBehaviour != this._src.onDisableBehaviour))
            {
                this._src.preset = VisualManagerPreset.Custom;
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(this._src);
            }
        }
Exemple #3
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtils.SetGUIStyles(null);
            EditorGUIUtility.labelWidth = 80f;
            EditorGUIUtils.InspectorLogo();
            VisualManagerPreset preset = this._src.preset;

            this._src.preset = (VisualManagerPreset)EditorGUILayout.EnumPopup("Preset", (Enum)(object)this._src.preset);
            if (preset != this._src.preset)
            {
                VisualManagerPreset preset2 = this._src.preset;
                if (preset2 == VisualManagerPreset.PoolingSystem)
                {
                    this._src.onEnableBehaviour  = OnEnableBehaviour.RestartFromSpawnPoint;
                    this._src.onDisableBehaviour = OnDisableBehaviour.Rewind;
                }
            }
            GUILayout.Space(6f);
            bool flag = this._src.preset != VisualManagerPreset.Custom;
            OnEnableBehaviour  onEnableBehaviour  = this._src.onEnableBehaviour;
            OnDisableBehaviour onDisableBehaviour = this._src.onDisableBehaviour;

            this._src.onEnableBehaviour  = (OnEnableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Enable", "Eventual actions to perform when this gameObject is activated"), (Enum)(object)this._src.onEnableBehaviour);
            this._src.onDisableBehaviour = (OnDisableBehaviour)EditorGUILayout.EnumPopup(new GUIContent("On Disable", "Eventual actions to perform when this gameObject is deactivated"), (Enum)(object)this._src.onDisableBehaviour);
            if (flag && onEnableBehaviour != this._src.onEnableBehaviour)
            {
                goto IL_0156;
            }
            if (onDisableBehaviour != this._src.onDisableBehaviour)
            {
                goto IL_0156;
            }
            goto IL_0162;
IL_0162:
            if (GUI.changed)
            {
                EditorUtility.SetDirty(this._src);
            }
            return;

IL_0156:
            this._src.preset = VisualManagerPreset.Custom;
            goto IL_0162;
        }