예제 #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfDirtyOrScript();

            var limitTouches    = (minTouches.intValue > 0) || (maxTouches.intValue > 0);
            var newLimitTouches = EditorGUILayout.ToggleLeft(LIMIT_TOUCHES, limitTouches);

            if (newLimitTouches)
            {
                if (!limitTouches)
                {
                    minTouchesFloat = 0;
                    maxTouchesFloat = 10;
                }
                EditorGUI.indentLevel++;
                EditorGUILayout.LabelField("Min: " + (int)minTouchesFloat + ", Max: " + (int)maxTouchesFloat);
                EditorGUILayout.MinMaxSlider(ref minTouchesFloat, ref maxTouchesFloat, 0, 10);
                EditorGUI.indentLevel--;
            }
            else
            {
                if (limitTouches)
                {
                    minTouchesFloat = 0;
                    maxTouchesFloat = 0;
                }
            }

            minTouches.intValue = (int)minTouchesFloat;
            maxTouches.intValue = (int)maxTouchesFloat;

            EditorGUI.BeginChangeCheck();
            var expanded = GUIElements.BeginFoldout(advanced.isExpanded, TEXT_ADVANCED_HEADER);

            if (EditorGUI.EndChangeCheck())
            {
                advanced.isExpanded = expanded;
            }
            if (expanded)
            {
                GUILayout.BeginVertical(GUIElements.FoldoutStyle);
                drawAdvanced();
                GUILayout.EndVertical();
            }
            GUIElements.EndFoldout();
            drawFriendlyGestures();

            serializedObject.ApplyModifiedProperties();
        }
예제 #2
0
        protected virtual void drawFriendlyGestures()
        {
            EditorGUI.BeginChangeCheck();
            var expanded = GUIElements.BeginFoldout(friendlyGestures.isExpanded, new GUIContent(string.Format("Friendly gestures ({0})", friendlyGestures.arraySize), TEXT_FRIENDLY_HEADER));

            if (EditorGUI.EndChangeCheck())
            {
                friendlyGestures.isExpanded = expanded;
            }
            if (expanded)
            {
                GUILayout.BeginVertical(GUIElements.FoldoutStyle);
                drawGestureList(friendlyGestures, addFriendlyGesture);
                GUILayout.EndVertical();
            }
            GUIElements.EndFoldout();
        }
예제 #3
0
        private void drawAdvanced()
        {
            EditorGUI.BeginChangeCheck();
            var expanded = GUIElements.BeginFoldout(advanced.isExpanded, new GUIContent("Advanced", TEXT_FRIENDLY_HEADER));

            if (EditorGUI.EndChangeCheck())
            {
                advanced.isExpanded = expanded;
            }
            if (expanded)
            {
                GUILayout.BeginVertical(GUIElements.FoldoutStyle);
                drawSendMessage();
                drawCombineTouches();
                drawRequireToFail();
                GUILayout.EndVertical();
            }
            GUIElements.EndFoldout();
        }
예제 #4
0
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfDirtyOrScript();

            EditorGUI.BeginChangeCheck();
            var expanded = GUIElements.BeginFoldout(advanced.isExpanded, new GUIContent("Advanced", TEXT_ADVANCED_HEADER));

            if (EditorGUI.EndChangeCheck())
            {
                advanced.isExpanded = expanded;
            }
            if (expanded)
            {
                GUILayout.BeginVertical(GUIElements.FoldoutStyle);
                drawAdvanced();
                GUILayout.EndVertical();
            }
            GUIElements.EndFoldout();

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
#if UNITY_5_6_OR_NEWER
            serializedObject.UpdateIfRequiredOrScript();
#else
            serializedObject.UpdateIfDirtyOrScript();
#endif

            EditorGUI.BeginChangeCheck();
            var expanded = GUIElements.BeginFoldout(advanced.isExpanded, TEXT_ADVANCED_HEADER);
            if (EditorGUI.EndChangeCheck())
            {
                advanced.isExpanded = expanded;
            }
            if (expanded)
            {
                GUILayout.BeginVertical(GUIElements.FoldoutStyle);
                drawAdvanced();
                GUILayout.EndVertical();
            }
            GUIElements.EndFoldout();

            serializedObject.ApplyModifiedProperties();
        }
예제 #6
0
        public override void OnInspectorGUI()
        {
            if (layerButtonStyle == null)
            {
                layerButtonStyle               = new GUIStyle(EditorStyles.miniButton);
                layerButtonStyle.fontSize      = 9;
                layerButtonStyle.contentOffset = new Vector2(0, 0);
            }

            serializedObject.Update();

            var r     = EditorGUILayout.GetControlRect(true, 16f, EditorStyles.objectField);
            var label = EditorGUI.BeginProperty(r, DISPLAY_DEVICE, displayDevice);

            EditorGUI.BeginChangeCheck();
            r = EditorGUI.PrefixLabel(r, label);
            var newDevice = EditorGUI.ObjectField(r, instance.DisplayDevice as Object, typeof(IDisplayDevice), true) as IDisplayDevice;

            if (EditorGUI.EndChangeCheck())
            {
                instance.DisplayDevice = newDevice;
                EditorUtility.SetDirty(instance);
            }
            EditorGUI.EndProperty();

            EditorGUIUtility.labelWidth = 160;
            EditorGUILayout.PropertyField(useSendMessage, USE_SEND_MESSAGE);
            if (useSendMessage.boolValue)
            {
                EditorGUILayout.PropertyField(sendMessageTarget, SEND_MESSAGE_TARGET);

                r     = EditorGUILayout.GetControlRect(true, 16f, EditorStyles.layerMaskField);
                label = EditorGUI.BeginProperty(r, SEND_MESSAGE_EVENTS, sendMessageEvents);
                EditorGUI.BeginChangeCheck();
                r = EditorGUI.PrefixLabel(r, label);
                var sMask = (TouchManager.MessageType)EditorGUI.EnumMaskField(r, instance.SendMessageEvents);
                if (EditorGUI.EndChangeCheck())
                {
                    instance.SendMessageEvents = sMask;
                    EditorUtility.SetDirty(instance);
                }
                EditorGUI.EndProperty();
            }

            if (Application.isPlaying)
            {
                GUI.enabled = false;
            }

            showLayers = GUIElements.BeginFoldout(showLayers, new GUIContent(String.Format("Layers ({0})", layers.arraySize)));
            if (showLayers)
            {
                EditorGUILayout.BeginVertical();
                for (int i = 0; i < layers.arraySize; i++)
                {
                    var    layer = layers.GetArrayElementAtIndex(i).objectReferenceValue as TouchLayer;
                    string name;
                    if (layer == null)
                    {
                        name = "Unknown";
                    }
                    else
                    {
                        name = layer.Name;
                    }

                    var rect = EditorGUILayout.BeginHorizontal(GUIElements.BoxStyle, GUILayout.Height(23));

                    EditorGUILayout.LabelField(name, GUIElements.BoxLabelStyle, GUILayout.ExpandWidth(true));
                    if (GUILayout.Button(MOVE_DOWN, layerButtonStyle, GUILayout.Width(20), GUILayout.Height(18)))
                    {
                        layers.MoveArrayElement(i, i + 1);
                    }
                    else if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
                    {
                        EditorGUIUtility.PingObject(layer);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();

                GUILayout.Space(5f);
                if (GUILayout.Button("Refresh", GUILayout.MaxWidth(100)))
                {
                    refresh();
                }
            }
            GUIElements.EndFoldout();

            GUI.enabled = true;
            serializedObject.ApplyModifiedProperties();
        }