Beispiel #1
0
    public override void OnInspectorGUI()
    {
        SWP_SlotMachine _SlotMachineScript = (SWP_SlotMachine)target;

        #region GLOBAL STATIC CONTROLS
        if (SWP_SlotMachineEditor.ShowHeader)
        {
            GetHeader();
        }

        if (SWP_SlotMachineEditor.ShowTitles)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            EditorGUILayout.LabelField("Slot Machine Globals");
            EditorGUILayout.EndHorizontal();
        }

                #if UNITY_4_3
        EditorGUILayout.BeginVertical(EditorStyles.miniButtonMid);
        SWP_SlotMachineEditor.ShowHeader             = EditorGUILayout.ToggleLeft("Show Editor Header", SWP_SlotMachineEditor.ShowHeader);
        SWP_SlotMachineEditor.ShowTitles             = EditorGUILayout.ToggleLeft("Show Editor Titles", SWP_SlotMachineEditor.ShowTitles);
        SWP_SlotMachineEditor.ShowQuickDebugControls = EditorGUILayout.ToggleLeft("Show Debug Controls", SWP_SlotMachineEditor.ShowQuickDebugControls);
                #else
        EditorGUILayout.BeginVertical();
        SWP_SlotMachineEditor.ShowHeader             = EditorGUILayout.Toggle("Show Editor Header", SWP_SlotMachineEditor.ShowHeader);
        SWP_SlotMachineEditor.ShowTitles             = EditorGUILayout.Toggle("Show Editor Titles", SWP_SlotMachineEditor.ShowTitles);
        SWP_SlotMachineEditor.ShowQuickDebugControls = EditorGUILayout.Toggle("Show Debug Controls", SWP_SlotMachineEditor.ShowQuickDebugControls);
                #endif
        EditorGUILayout.EndVertical();
        #endregion

        #region SOUND CONTROLS
        EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                #if UNITY_4_3
        _SlotMachineScript.EnableSound = EditorGUILayout.ToggleLeft("Enable Sound", _SlotMachineScript.EnableSound);
                #else
        _SlotMachineScript.EnableSound = EditorGUILayout.Toggle("Enable Sound", _SlotMachineScript.EnableSound);
                #endif
        EditorGUILayout.EndHorizontal();

        if (_SlotMachineScript.EnableSound)
        {
                        #if UNITY_4_3
            EditorGUILayout.BeginVertical(EditorStyles.miniButtonMid);
                        #else
            EditorGUILayout.BeginVertical();
                        #endif
            _SlotMachineScript.SoundVolume        = EditorGUILayout.Slider("Sound Volume", _SlotMachineScript.SoundVolume, 0f, 1f);
            _SlotMachineScript.ReelSpinSound      = (AudioClip)EditorGUILayout.ObjectField("Spin Audio", _SlotMachineScript.ReelSpinSound, typeof(AudioClip), false);
            _SlotMachineScript.ReelStopSound      = (AudioClip)EditorGUILayout.ObjectField("Stop Audio", _SlotMachineScript.ReelStopSound, typeof(AudioClip), false);
            _SlotMachineScript.ReelWinSound       = (AudioClip)EditorGUILayout.ObjectField("Win Audio", _SlotMachineScript.ReelWinSound, typeof(AudioClip), false);
            _SlotMachineScript.ReelNudgeUpSound   = (AudioClip)EditorGUILayout.ObjectField("Nudge Up Audio", _SlotMachineScript.ReelNudgeUpSound, typeof(AudioClip), false);
            _SlotMachineScript.ReelNudgeDownSound = (AudioClip)EditorGUILayout.ObjectField("Nudge Down Audio", _SlotMachineScript.ReelNudgeDownSound, typeof(AudioClip), false);
            EditorGUILayout.EndVertical();
        }
        #endregion

        #region MAIN SLOT SETTINGS
        if (SWP_SlotMachineEditor.ShowTitles)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            EditorGUILayout.LabelField("Slot Machine Controls (Reels = " + _SlotMachineScript.AllReels.Count.ToString() + ")");
            EditorGUILayout.EndHorizontal();
        }

                #if UNITY_4_3
        EditorGUILayout.BeginVertical(EditorStyles.miniButtonMid);
                #else
        EditorGUILayout.BeginVertical();
                #endif
        _SlotMachineScript.PreSpinDuration = EditorGUILayout.Slider("Pre-Spin (Seconds)", _SlotMachineScript.PreSpinDuration, 1f, 10f);
        _SlotMachineScript.SpeedModifier   = EditorGUILayout.FloatField("Spin Speed Modifier", _SlotMachineScript.SpeedModifier);

                #if UNITY_4_3
        _SlotMachineScript.EnableMiddleLineWin = EditorGUILayout.ToggleLeft("Enable Main Line Win", _SlotMachineScript.EnableMiddleLineWin);
        _SlotMachineScript.EnableTopLineWin    = EditorGUILayout.ToggleLeft("Enable Top Line Win", _SlotMachineScript.EnableTopLineWin);
        _SlotMachineScript.EnableBottomLineWin = EditorGUILayout.ToggleLeft("Enable Bottom Line Win", _SlotMachineScript.EnableBottomLineWin);
                #else
        _SlotMachineScript.EnableMiddleLineWin = EditorGUILayout.Toggle("Enable Main Line Win", _SlotMachineScript.EnableMiddleLineWin);
        _SlotMachineScript.EnableTopLineWin    = EditorGUILayout.Toggle("Enable Top Line Win", _SlotMachineScript.EnableTopLineWin);
        _SlotMachineScript.EnableBottomLineWin = EditorGUILayout.Toggle("Enable Bottom Line Win", _SlotMachineScript.EnableBottomLineWin);
                #endif

        if (_SlotMachineScript.AllReels.Count > 0)
        {
                        #if UNITY_4_3
            _SlotMachineScript.EnableFixSpin = EditorGUILayout.ToggleLeft("Fix The Reels", _SlotMachineScript.EnableFixSpin);
                        #else
            _SlotMachineScript.EnableFixSpin = EditorGUILayout.Toggle("Fix The Reels", _SlotMachineScript.EnableFixSpin);
                        #endif
        }

        if (GUILayout.Button("Add New Reel") && Application.isEditor)
        {
            AddNewReel(_SlotMachineScript);
        }

        for (int thisCounter = 0; thisCounter < _SlotMachineScript.AllReels.Count; thisCounter++)
        {
            GetReelLine(_SlotMachineScript, thisCounter);

            GetReelItemLines(_SlotMachineScript, thisCounter);
        }

        EditorGUILayout.EndVertical();
        #endregion

        #region DEBUG SECTION CONTROLS
        if (SWP_SlotMachineEditor.ShowQuickDebugControls)
        {
            if (SWP_SlotMachineEditor.ShowTitles)
            {
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                EditorGUILayout.LabelField("Quick Debug Controls");
                EditorGUILayout.EndHorizontal();
            }

                        #if UNITY_4_3
            EditorGUILayout.BeginVertical(EditorStyles.miniButtonMid);
                        #else
            EditorGUILayout.BeginVertical();
                        #endif
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Auto Start / Stop") && Application.isPlaying)
            {
                _SlotMachineScript.StartStopReels();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Start Reels") && Application.isPlaying)
            {
                _SlotMachineScript.StartReels();
            }

            if (GUILayout.Button("Stop Reels") && Application.isPlaying)
            {
                _SlotMachineScript.StopReels();
            }

            EditorGUILayout.EndHorizontal();

            if (_SlotMachineScript.AllReels.Count > 0)
            {
                if (SWP_SlotMachineEditor.ShowTitles)
                {
                    EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                    EditorGUILayout.LabelField("Quick Nudges");
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal();

                for (int thisCounter = 0; thisCounter < _SlotMachineScript.AllReels.Count; thisCounter++)
                {
                    if (GUILayout.Button(thisCounter.ToString("00") + "U") && Application.isPlaying)
                    {
                        _SlotMachineScript.NudgeReels(true, thisCounter);
                    }
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();

                for (int thisCounter = 0; thisCounter < _SlotMachineScript.AllReels.Count; thisCounter++)
                {
                    if (GUILayout.Button(thisCounter.ToString("00") + "D") && Application.isPlaying)
                    {
                        _SlotMachineScript.NudgeReels(false, thisCounter);
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
        }
        #endregion

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_SlotMachineScript);
        }

        this.Repaint();
    }