예제 #1
0
        private void drawUnityEvents()
        {
            var display = GUIElements.Header(TEXT_USE_UNITY_EVENTS_HEADER, useUnityEvents, useUnityEvents, useUnityEvents_prop);

            if (display)
            {
                EditorGUI.indentLevel++;
                using (new EditorGUI.DisabledGroupScope(!useUnityEvents.boolValue))
                {
                    EditorGUILayout.PropertyField(OnFrameStart);
                    EditorGUILayout.PropertyField(OnFrameFinish);
                    EditorGUILayout.PropertyField(OnPointersAdd);
                    EditorGUILayout.PropertyField(OnPointersUpdate);
                    EditorGUILayout.PropertyField(OnPointersPress);
                    EditorGUILayout.PropertyField(OnPointersRelease);
                    EditorGUILayout.PropertyField(OnPointersRemove);
                    EditorGUILayout.PropertyField(OnPointersCancel);
                }
                EditorGUI.indentLevel--;
            }
        }
        private void drawGeneral()
        {
            var display = GUIElements.Header(TEXT_GENERAL_HEADER, generalProps);

            if (display)
            {
                EditorGUI.indentLevel++;

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(emulateSecondMousePointer, TEXT_EMULATE_MOUSE);
                if (EditorGUI.EndChangeCheck())
                {
                    instance.EmulateSecondMousePointer = emulateSecondMousePointer.boolValue;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(TEXT_FAKE_GESTURE.text);
                EditorGUILayout.EnumPopup(instance.FakeGestureType);
                GUILayout.EndHorizontal();

                EditorGUI.indentLevel--;
            }
        }
예제 #3
0
        public override void OnInspectorGUI()
        {
#if UNITY_5_6_OR_NEWER
            serializedObject.UpdateIfRequiredOrScript();
#else
            serializedObject.UpdateIfDirtyOrScript();
#endif

            GUILayout.Space(5);
            bool display;

            if (basicEditor.boolValue)
            {
                drawBasic();
                if (GUIElements.BasicHelpBox(getHelpText()))
                {
                    basicEditor.boolValue = false;
                    Repaint();
                }
            }
            else
            {
                if (shouldDrawGeneral)
                {
                    display = GUIElements.Header(TEXT_GENERAL_HEADER, generalProps);
                    if (display)
                    {
                        EditorGUI.indentLevel++;
                        drawGeneral();
                        EditorGUI.indentLevel--;
                    }
                }

                drawOtherGUI();

                display = GUIElements.Header(TEXT_LIMITS_HEADER, limitsProps);
                if (display)
                {
                    EditorGUI.indentLevel++;
                    drawLimits();
                    EditorGUI.indentLevel--;
                }

                display = GUIElements.Header(TEXT_GESTURES_HEADER, friendlyGestures);
                if (display)
                {
                    EditorGUI.indentLevel++;
                    drawFriendlyGestures();
                    drawRequireToFail();
                    GUILayout.Space(5);
                    EditorGUI.indentLevel--;
                }

                display = GUIElements.Header(TEXT_USE_UNITY_EVENTS_HEADER, useUnityEvents, useUnityEvents, useUnityEvents_prop);
                if (display)
                {
                    EditorGUI.indentLevel++;
                    using (new EditorGUI.DisabledGroupScope(!useUnityEvents.boolValue))
                    {
                        drawUnityEvents();
                    }
                    EditorGUI.indentLevel--;
                }

                display = GUIElements.Header(TEXT_USE_SEND_MESSAGE_HEADER, useSendMessage, useSendMessage, useSendMessage_prop);
                if (display)
                {
                    EditorGUI.indentLevel++;
                    using (new EditorGUI.DisabledGroupScope(!useSendMessage.boolValue))
                    {
                        drawSendMessage();
                    }
                    EditorGUI.indentLevel--;
                }

                if (shouldDrawAdvanced)
                {
                    display = GUIElements.Header(TEXT_ADVANCED_HEADER, advancedProps);
                    if (display)
                    {
                        EditorGUI.indentLevel++;
                        drawAdvanced();
                        EditorGUI.indentLevel--;
                    }
                }

                drawDebug();
            }

            serializedObject.ApplyModifiedProperties();
        }
        /// <summary>
        /// Draws inspector for a Slide Deck.
        /// </summary>
        /// <param name="deck">Slide Deck to draw.</param>
        /// <param name="scroll">Current vertical scroll value.</param>
        /// <param name="shouldSelect">A function which returns if the current slide should be selected.</param>
        /// <param name="onPlayPress">A function called when "Play" button of a slide is pressed.</param>
        /// <returns>Current vertical scroll value.</returns>
        public static float DrawInspector(SlideDeck deck, float scroll, Func <SlideDeck, int, bool> shouldSelect = null, Action <SlideDeck, int> onPlayPress = null)
        {
            if (styles == null)
            {
                styles = new Styles();
            }

            ReorderableList list;
            var             key = deck.GetInstanceID() + "#" + (shouldSelect != null) + "#" + (onPlayPress != null);

            if (!lists.TryGetValue(key, out list))
            {
                // Init a ReorderableList for the deck and cache it.
                list = new ReorderableList(deck.Slides, typeof(PresentationSlide), true, true, true, true);
                lists.Add(key, list);

                list.onChangedCallback += (l) =>
                {
//					deck.Save();
                };

                list.drawHeaderCallback += (Rect rect) => GUI.Label(rect, deck.IsSavedOnDisk ? deck.Name + ".asset" : "<not saved>");

                list.elementHeightCallback += (int index) => styles.ELEMENT_HEIGHT;

                list.drawElementBackgroundCallback += (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        if (index < 0)
                        {
                            return;
                        }

                        var bgcolor = GUI.backgroundColor;
                        var slide   = deck.Slides[index];

                        if (shouldSelect != null && shouldSelect(deck, index))
                        {
                            GUI.backgroundColor = styles.SELECTED_COLOR;
                            rect.height        += 3;
                            styles.BG_SELECTED.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        else
                        if (slide.Visible || isFocused)
                        {
                            styles.BG.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        else
                        {
                            GUI.backgroundColor = styles.INVISIBLE_COLOR;
                            rect.height        += 3;
                            styles.BG_INVISIBLE.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        GUI.backgroundColor = bgcolor;
                    }
                };

                list.drawElementCallback += (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    var changed = false;
                    var color   = GUI.color;
                    var slide   = deck.Slides[index];

                    // visible
                    EditorGUI.BeginChangeCheck();
                    if (!slide.Visible)
                    {
                        GUI.color = styles.INACTIVE_COLOR;
                    }
                    var newVisible = GUI.Toggle(
                        new Rect(rect.x, rect.y, styles.ICON.fixedWidth, rect.height), slide.Visible, styles.VISIBLE_ICON, styles.ICON);
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.Visible = newVisible;
                        changed       = true;
                    }
                    GUI.color = color;
                    rect.x   += styles.ICON.fixedWidth;

                    // play mode
                    EditorGUI.BeginChangeCheck();
                    if (!slide.StartInPlayMode)
                    {
                        GUI.color = styles.INACTIVE_COLOR;
                    }
                    var newPlaymode = GUI.Toggle(
                        new Rect(rect.x, rect.y, styles.ICON.fixedWidth, rect.height), slide.StartInPlayMode, styles.PLAYMODE_ICON, styles.ICON);
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.StartInPlayMode = newPlaymode;
                        changed = true;
                    }
                    GUI.color = color;
                    rect.x   += styles.ICON.fixedWidth;

                    // scene
                    var w = rect.width - styles.ICON.fixedWidth * 2;
                    if (onPlayPress != null)
                    {
                        w -= styles.PLAY_BUTTON.fixedWidth + 6;
                    }
                    var scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(slide.ScenePath);
                    EditorGUI.BeginChangeCheck();
                    var newScene = EditorGUI.ObjectField(new Rect(rect.x, rect.y + 2, w, rect.height - 4), scene, typeof(SceneAsset), false) as SceneAsset;
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.Scene = newScene;
                        changed     = true;
                    }
                    rect.x += w + 6;

                    if (onPlayPress != null)
                    {
                        rect.y += 2;
                        if (GUI.Button(rect, styles.PLAY_ICON, styles.PLAY_BUTTON))
                        {
                            onPlayPress(deck, index);
                        }
                    }

                    if (changed)
                    {
                        deck.Save();
                    }
                };
            }

            scroll = EditorGUILayout.BeginScrollView(new Vector2(0, scroll), false, false, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)).y;
            var r = GUILayoutUtility.GetRect(0, list.GetHeight() + 20);

            list.DoList(r);

            var propsName   = "presentation_" + deck.name + "_options";
            var showOptions = EditorPrefs.GetBool(propsName, false);

            showOptions = GUIElements.Header(styles.TEXT_OPTIONS, showOptions);
            if (showOptions)
            {
                EditorGUI.indentLevel++;
                deck.BackgroundColor = EditorGUILayout.ColorField(styles.TEXT_BG_COLOR, deck.BackgroundColor, true, false, false, new ColorPickerHDRConfig(0, 1, 0, 1), GUILayout.ExpandWidth(true));
                EditorGUI.indentLevel--;
            }
            EditorPrefs.SetBool(propsName, showOptions);
            EditorGUILayout.EndScrollView();

            return(scroll);
        }