Example #1
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();
        }
Example #2
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);
     }
 }
Example #3
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();
        }