Exemple #1
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();
        EditorGUI.indentLevel = 0;

        var ma = MasterAudio.Instance;

        if (ma != null)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.logoTexture);
        }

        ButtonClicker sounds = (ButtonClicker)target;

        maInScene = ma != null;
        if (maInScene)
        {
            groupNames = ma.GroupNames;
        }

        var resizeOnClick = EditorGUILayout.Toggle("Resize On Click", sounds.resizeOnClick);

        if (resizeOnClick != sounds.resizeOnClick)
        {
            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Resize On Click");
            sounds.resizeOnClick = resizeOnClick;
        }

        var resizeOnHover = EditorGUILayout.Toggle("Resize On Hover", sounds.resizeOnHover);

        if (resizeOnHover != sounds.resizeOnHover)
        {
            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Resize On Hover");
            sounds.resizeOnHover = resizeOnHover;
        }

        EditSoundGroup(sounds, ref sounds.mouseDownSound, "Mouse Down Sound");
        EditSoundGroup(sounds, ref sounds.mouseUpSound, "Mouse Up Sound");
        EditSoundGroup(sounds, ref sounds.mouseClickSound, "Mouse Click Sound");
        EditSoundGroup(sounds, ref sounds.mouseOverSound, "Mouse Over Sound");
        EditSoundGroup(sounds, ref sounds.mouseOutSound, "Mouse Out Sound");

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

        this.Repaint();

        //DrawDefaultInspector();
    }
    void EditSoundGroup(ButtonClicker sounds, ref string soundGroup, string label)
    {
        if (maInScene) {
            var existingIndex = groupNames.IndexOf(soundGroup);

            int? groupIndex = null;

            var noMatch = false;

            if (existingIndex >= 1) {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, groupNames.ToArray());
            } else if (existingIndex == -1 && soundGroup == MasterAudio.NO_GROUP_NAME) {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, groupNames.ToArray());
            } else { // non-match
                noMatch = true;

                var newGroup = EditorGUILayout.TextField(label, soundGroup);
                if (newGroup != soundGroup) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                    soundGroup = newGroup;
                }
                var newIndex = EditorGUILayout.Popup("All Sound Types", -1, groupNames.ToArray());
                if (newIndex >= 0) {
                    groupIndex = newIndex;
                }
            }

            if (noMatch) {
                DTGUIHelper.ShowRedError("Sound Type found no match. Choose one from 'All Sound Types'.");
            }

            if (groupIndex.HasValue) {
                if (existingIndex != groupIndex.Value) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                }
                if (groupIndex.Value == -1) {
                    soundGroup = MasterAudio.NO_GROUP_NAME;
                } else {
                    soundGroup = groupNames[groupIndex.Value];
                }
            }
        } else {
            var newGroup = EditorGUILayout.TextField(label, soundGroup);
            if (newGroup != soundGroup) {
                soundGroup = newGroup;
                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
            }
        }
    }
    public void InstantiateLevelField(int widthInBlocks, int heightInBlocks)
    {
        ButtonClicker.DestroyCanvasObjects();

        var wallBlockRectTransform = EditorPrefabsSettings.Prefabs.TileButton.GetComponent <RectTransform>();
        var blockWidth             = wallBlockRectTransform.rect.width;
        var blockHight             = wallBlockRectTransform.rect.height;

        var ContentTransform    = MainLayerOnCanvas.transform;
        var canvasRectTransform = ContentTransform.GetComponent <RectTransform>();

        canvasRectTransform.sizeDelta = new Vector2(widthInBlocks * blockWidth + 65, heightInBlocks * blockHight + 65);

        var SpikeTransform           = SpikeLayerOnCanvas.transform;
        var canvasSpikeRectTransform = SpikeTransform.GetComponent <RectTransform>();

        canvasSpikeRectTransform.sizeDelta = new Vector2(widthInBlocks * blockWidth + 65, heightInBlocks * blockHight + 65);

        InstantiateLevelField();
    }
Exemple #4
0
    protected void EditSoundGroup(ButtonClicker sounds, ref string soundGroup, string label)
    {
        DTGUIHelper.StartGroupHeader();
        if (_maInScene)
        {
            var existingIndex = _groupNames.IndexOf(soundGroup);

            int?groupIndex = null;

            var noMatch = false;

            if (existingIndex >= 1)
            {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, _groupNames.ToArray());
            }
            else if (existingIndex == -1 && soundGroup == MasterAudio.NoGroupName)
            {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, _groupNames.ToArray());
            }
            else     // non-match
            {
                noMatch = true;

                var newGroup = EditorGUILayout.TextField(label, soundGroup);
                if (newGroup != soundGroup)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, sounds, "change Sound Group");
                    soundGroup = newGroup;
                }
                var newIndex = EditorGUILayout.Popup("All Sound Types", -1, _groupNames.ToArray());
                if (newIndex >= 0)
                {
                    groupIndex = newIndex;
                }
            }

            if (noMatch)
            {
                DTGUIHelper.ShowRedError("Sound Type found no match. Choose one from 'All Sound Types'.");
            }

            if (!groupIndex.HasValue)
            {
                DTGUIHelper.EndGroupHeader();
                return;
            }

            if (existingIndex != groupIndex.Value)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, sounds, "change Sound Group");
            }
            // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
            if (groupIndex.Value == -1)
            {
                soundGroup = MasterAudio.NoGroupName;
            }
            else
            {
                soundGroup = _groupNames[groupIndex.Value];
            }
        }
        else
        {
            var newGroup = EditorGUILayout.TextField(label, soundGroup);
            if (newGroup == soundGroup)
            {
                DTGUIHelper.EndGroupHeader();
                return;
            }

            soundGroup = newGroup;
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, sounds, "change Sound Group");
        }
        DTGUIHelper.EndGroupHeader();
    }
Exemple #5
0
    void EditSoundGroup(ButtonClicker sounds, ref string soundGroup, string label)
    {
        if (maInScene)
        {
            var existingIndex = groupNames.IndexOf(soundGroup);

            int?groupIndex = null;

            var noMatch = false;

            if (existingIndex >= 1)
            {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, groupNames.ToArray());
            }
            else if (existingIndex == -1 && soundGroup == MasterAudio.NO_GROUP_NAME)
            {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, groupNames.ToArray());
            }
            else                 // non-match
            {
                noMatch = true;

                var newGroup = EditorGUILayout.TextField(label, soundGroup);
                if (newGroup != soundGroup)
                {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                    soundGroup = newGroup;
                }
                var newIndex = EditorGUILayout.Popup("All Sound Types", -1, groupNames.ToArray());
                if (newIndex >= 0)
                {
                    groupIndex = newIndex;
                }
            }

            if (noMatch)
            {
                DTGUIHelper.ShowRedError("Sound Type found no match. Choose one from 'All Sound Types'.");
            }

            if (groupIndex.HasValue)
            {
                if (existingIndex != groupIndex.Value)
                {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                }
                if (groupIndex.Value == -1)
                {
                    soundGroup = MasterAudio.NO_GROUP_NAME;
                }
                else
                {
                    soundGroup = groupNames[groupIndex.Value];
                }
            }
        }
        else
        {
            var newGroup = EditorGUILayout.TextField(label, soundGroup);
            if (newGroup != soundGroup)
            {
                soundGroup = newGroup;
                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
            }
        }
    }
    protected void EditSoundGroup(ButtonClicker sounds, ref string soundGroup, string label) {
        DTGUIHelper.AddSpaceForNonU5(2);
        DTGUIHelper.StartGroupHeader();
        if (_maInScene) {
            var existingIndex = _groupNames.IndexOf(soundGroup);

            int? groupIndex = null;

            var noMatch = false;

            if (existingIndex >= 1) {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, _groupNames.ToArray());
            } else if (existingIndex == -1 && soundGroup == MasterAudio.NoGroupName) {
                groupIndex = EditorGUILayout.Popup(label, existingIndex, _groupNames.ToArray());
            } else { // non-match
                noMatch = true;

                var newGroup = EditorGUILayout.TextField(label, soundGroup);
                if (newGroup != soundGroup) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, sounds, "change Sound Group");
                    soundGroup = newGroup;
                }
                var newIndex = EditorGUILayout.Popup("All Sound Types", -1, _groupNames.ToArray());
                if (newIndex >= 0) {
                    groupIndex = newIndex;
                }
            }

            if (noMatch) {
                DTGUIHelper.ShowRedError("Sound Type found no match. Choose one from 'All Sound Types'.");
            }

            if (!groupIndex.HasValue)
            {
                DTGUIHelper.EndGroupHeader();
                return;
            }

            if (existingIndex != groupIndex.Value) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, sounds, "change Sound Group");
            }
            // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
            if (groupIndex.Value == -1) {
                soundGroup = MasterAudio.NoGroupName;
            } else {
                soundGroup = _groupNames[groupIndex.Value];
            }
        } else {
            var newGroup = EditorGUILayout.TextField(label, soundGroup);
            if (newGroup == soundGroup) {
                DTGUIHelper.EndGroupHeader();
                return;
            }

            soundGroup = newGroup;
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, sounds, "change Sound Group");
        }
        DTGUIHelper.EndGroupHeader();
    }