Exemple #1
0
        /// <summary>
        /// Creates the GUI of the tap settings.
        /// </summary>
        private static void CreateTapSettingsGUI()
        {
            GUILayout.BeginVertical("HelpBox");
            GUILayout.Label("Tap Settings", EditorStyles.boldLabel);


            // Min tap duration
            GUILayout.BeginVertical("GroupBox");

            EditorGUILayout.LabelField("Min Tap Duration In Seconds", EditorStyles.largeLabel);
            inputSettings.minTapDuration = GUIFactory.CreateFloatFieldGUI(inputSettings.minTapDuration,
                                                                          0.0f,
                                                                          (float)double.PositiveInfinity);

            GUILayout.EndVertical();


            // Max tap duration
            GUILayout.BeginVertical("GroupBox");

            EditorGUILayout.LabelField("Max Tap Duration In Seconds", EditorStyles.largeLabel);
            inputSettings.maxTapDuration = GUIFactory.CreateFloatFieldGUI(inputSettings.maxTapDuration,
                                                                          0.0f,
                                                                          (float)double.PositiveInfinity);

            GUILayout.EndVertical();


            GUILayout.EndVertical();
        }
Exemple #2
0
        /// <summary>
        /// Process values from the editor and update the window.
        /// </summary>
        void OnGUI()
        {
            inputSettings = LoadSettingsAsset();

            if (!HasSettingsData())
            {
                GUILayout.Label("No input settings instance found in the resources folder, add one!", EditorStyles.boldLabel);
                return;
            }

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            CreateSwipeSettingsGUI();

            GUIFactory.AddGUISpace(3);

            CreateTapSettingsGUI();

            GUIFactory.AddGUISpace(3);

            CreateTiltSettingsGUI();

            EditorGUILayout.EndScrollView();

            SaveSettings();
        }
Exemple #3
0
        /// <summary>
        /// Creates the GUI of the swipe settings.
        /// </summary>
        private static void CreateSwipeSettingsGUI()
        {
            GUILayout.BeginVertical("HelpBox");
            GUILayout.Label("Swipe Settings", EditorStyles.boldLabel);


            // Min horizontal swipe length slider
            GUILayout.BeginVertical("GroupBox");

            GUIFactory.CreateSlider("Min Horizontal Swipe Length (Completed Swipes)",
                                    EditorStyles.largeLabel,
                                    "Needed horizontal swipe length to register a swipe. Measured in screen percent",
                                    ref inputSettings.minHorizontalSwipeLength,
                                    0.0f,
                                    100.0f);

            GUILayout.EndVertical();


            // Min vertical swipe length slider
            GUILayout.BeginVertical("GroupBox");

            GUIFactory.CreateSlider("Min Vertical Swipe Length (Completed Swipes)",
                                    EditorStyles.largeLabel,
                                    "Needed vertical swipe length to register a swipe. Measured in screen percent",
                                    ref inputSettings.minVerticalSwipeLength,
                                    0.0f,
                                    100.0f);

            GUILayout.EndVertical();

            GUILayout.EndVertical();
        }
Exemple #4
0
        /// <summary>
        /// Update inspector content.
        /// </summary>
        public override void OnInspectorGUI()
        {
            castedTargetComponent = (MobileInputReaction)target;

            serializedObject.Update();

            reactionFieldAmount           = GUIFactory.CreateIntFieldGUI("Reaction Amount (0 - 10):", castedTargetComponent.inputReactionFields.Count, 0, maxReactionFields);
            inputReactionFields.arraySize = reactionFieldAmount;

            ResizeUsageDictionary(ref useActionTriggerContainer);
            ResizeUsageDictionary(ref useArgumentTriggerContainer);

            HandleReactionFields();

            UpdateActionTriggerUsage(castedTargetComponent);
            UpdateArgumentTriggerUsage(castedTargetComponent);

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(castedTargetComponent);
                EditorSceneManager.MarkSceneDirty(castedTargetComponent.gameObject.scene);
            }
        }
Exemple #5
0
 /// <summary>
 /// Creates GUI spaces by the given amount.
 /// </summary>
 /// <param name="fieldIterator">Iterator value for the reaction field array.</param>
 private void CreateSpaceBetweenFields(int fieldIterator)
 {
     if (fieldIterator < inputReactionFields.arraySize - 1)
     {
         GUIFactory.AddGUISpace(3);
     }
 }
Exemple #6
0
        /// <summary>
        /// Creates the GUI of the tilt settings.
        /// </summary>
        private static void CreateTiltSettingsGUI()
        {
            GUILayout.BeginVertical("HelpBox");
            GUILayout.Label("Tilt Settings", EditorStyles.boldLabel);


            // Pos x-tilt treshold
            GUILayout.BeginVertical("GroupBox");

            EditorGUILayout.LabelField("Min Positive Needed X-Tilt (right) Treshold", EditorStyles.largeLabel);
            inputSettings.xTiltPosThreshold = GUIFactory.CreateFloatFieldGUI(inputSettings.xTiltPosThreshold,
                                                                             -1.0f,
                                                                             1.0f);

            GUILayout.EndVertical();


            // Neg x-tilt treshold
            GUILayout.BeginVertical("GroupBox");

            EditorGUILayout.LabelField("Min Negative Needed X-Tilt (left) Treshold", EditorStyles.largeLabel);
            inputSettings.xTiltNegThreshold = GUIFactory.CreateFloatFieldGUI(inputSettings.xTiltNegThreshold,
                                                                             -1.0f,
                                                                             1.0f);

            GUILayout.EndVertical();


            // Pos y-tilt treshold
            GUILayout.BeginVertical("GroupBox");

            EditorGUILayout.LabelField("Min Positive Needed Y-Tilt (forward) Treshold", EditorStyles.largeLabel);
            inputSettings.yTiltPosThreshold = GUIFactory.CreateFloatFieldGUI(inputSettings.yTiltPosThreshold,
                                                                             -1.0f,
                                                                             1.0f);

            GUILayout.EndVertical();


            // Neg y-tilt treshold
            GUILayout.BeginVertical("GroupBox");

            EditorGUILayout.LabelField("Min Negative Needed Y-Tilt (backward) Treshold", EditorStyles.largeLabel);
            inputSettings.yTiltNegThreshold = GUIFactory.CreateFloatFieldGUI(inputSettings.yTiltNegThreshold,
                                                                             -1.0f,
                                                                             1.0f);

            GUILayout.EndVertical();

            GUILayout.EndVertical();
        }
Exemple #7
0
        /// <summary>
        /// Creates or resets the reaction fields and creates GUI for them.
        /// </summary>
        private void HandleReactionFields()
        {
            for (int fieldIterator = 0; fieldIterator < inputReactionFields.arraySize; fieldIterator++)
            {
                GUI.backgroundColor = Color.black;
                GUILayout.BeginVertical("HelpBox");
                GUI.backgroundColor = Color.white;
                GUILayout.BeginVertical("Box");

                // Handle action triggers
                useActionTriggerContainer[fieldIterator] = GUIFactory.CreateToggleGUI("Use Action Input Triggers", useActionTriggerContainer[fieldIterator]);

                //if (castedTarget.useActionTriggerContainer.Count > 0 && castedTarget.useActionTriggerContainer.First().Value)
                if (useActionTriggerContainer[fieldIterator])
                {
                    GUIFactory.CreateReactionFieldGUI(fieldIterator,
                                                      "Action Input Triggers",
                                                      inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("inputActionTriggers"),
                                                      inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("m_OnActionTriggered"));
                }
                else
                {
                    ResetReactionField(inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("inputActionTriggers"),
                                       inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("m_OnActionTriggered"));
                }

                GUIFactory.AddGUISpace(3);

                // Handle argument triggers
                useArgumentTriggerContainer[fieldIterator] = GUIFactory.CreateToggleGUI("Use Argument Input Triggers", useArgumentTriggerContainer[fieldIterator]);

                if (useArgumentTriggerContainer[fieldIterator])
                {
                    GUIFactory.CreateReactionFieldGUI(fieldIterator,
                                                      "Argument Input Triggers",
                                                      inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("inputArgumentTriggers"),
                                                      inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("m_OnArgumentInputTriggered"));
                }
                else
                {
                    ResetReactionField(inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("inputArgumentTriggers"),
                                       inputReactionFields.GetArrayElementAtIndex(fieldIterator).FindPropertyRelative("m_OnArgumentInputTriggered"));
                }

                GUILayout.EndVertical();
                GUILayout.EndVertical();

                CreateSpaceBetweenFields(fieldIterator);
            }
        }
        /// <summary>
        /// Update inspector content.
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            CreateSwipeDataGUI();

            GUIFactory.AddGUISpace(3);

            CreateTapDataGUI();

            GUIFactory.AddGUISpace(3);

            CreateTiltDataGUI();

            serializedObject.ApplyModifiedProperties();
        }
        /// <summary>
        /// Creates GUI elements for tap settings data.
        /// </summary>
        private void CreateTapDataGUI()
        {
            EditorGUILayout.BeginVertical("HelpBox");

            EditorGUILayout.LabelField("Tap Settings", EditorStyles.boldLabel);

            EditorGUILayout.LabelField("Min Tap Duration In Seconds", EditorStyles.largeLabel);
            minTapDuration.floatValue = GUIFactory.CreateFloatFieldGUI(minTapDuration.floatValue,
                                                                       0.0f,
                                                                       (float)double.PositiveInfinity);

            GUIFactory.AddGUISpace(1);

            EditorGUILayout.LabelField("Max Tap Duration In Seconds", EditorStyles.largeLabel);
            maxTapDuration.floatValue = GUIFactory.CreateFloatFieldGUI(maxTapDuration.floatValue,
                                                                       0.0f,
                                                                       (float)double.PositiveInfinity);

            EditorGUILayout.EndVertical();
        }
        /// <summary>
        /// Creates GUI elements for swipe settings data.
        /// </summary>
        private void CreateSwipeDataGUI()
        {
            EditorGUILayout.BeginVertical("HelpBox");

            EditorGUILayout.LabelField("Swipe Settings", EditorStyles.boldLabel);

            EditorGUILayout.LabelField("Min Horizontal Swipe Length (in % of screen)", EditorStyles.largeLabel);
            minHorizontalSwipeLength.floatValue = GUIFactory.CreateFloatFieldGUI(minHorizontalSwipeLength.floatValue,
                                                                                 0.0f,
                                                                                 100.0f);

            GUIFactory.AddGUISpace(1);

            EditorGUILayout.LabelField("Min Vertical Swipe Length (in % of screen)", EditorStyles.largeLabel);
            minVerticalSwipeLength.floatValue = GUIFactory.CreateFloatFieldGUI(minVerticalSwipeLength.floatValue,
                                                                               0.0f,
                                                                               100.0f);

            EditorGUILayout.EndVertical();
        }
        /// <summary>
        /// Creates GUI elements for tilt settings data.
        /// </summary>
        private void CreateTiltDataGUI()
        {
            EditorGUILayout.BeginVertical("HelpBox");

            EditorGUILayout.LabelField("Tilt Settings", EditorStyles.boldLabel);

            EditorGUILayout.LabelField("Min Positive Needed X-Tilt (right)", EditorStyles.largeLabel);
            xTiltPosThreshold.floatValue = GUIFactory.CreateFloatFieldGUI(xTiltPosThreshold.floatValue,
                                                                          0.0f,
                                                                          1.0f);

            GUIFactory.AddGUISpace(1);

            EditorGUILayout.LabelField("Min Negative Needed X-Tilt (left)", EditorStyles.largeLabel);
            xTiltNegThreshold.floatValue = GUIFactory.CreateFloatFieldGUI(xTiltNegThreshold.floatValue,
                                                                          -1.0f,
                                                                          0.0f);


            GUIFactory.AddGUISpace(1);


            EditorGUILayout.LabelField("Min Positive Needed Y-Tilt (forward)", EditorStyles.largeLabel);
            yTiltPosThreshold.floatValue = GUIFactory.CreateFloatFieldGUI(yTiltPosThreshold.floatValue,
                                                                          0.0f,
                                                                          1.0f);

            GUIFactory.AddGUISpace(1);

            EditorGUILayout.LabelField("Min Negative Needed Y-Tilt (backward)", EditorStyles.largeLabel);
            yTiltNegThreshold.floatValue = GUIFactory.CreateFloatFieldGUI(yTiltNegThreshold.floatValue,
                                                                          -1.0f,
                                                                          0.0f);

            EditorGUILayout.EndVertical();
        }