private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            rect.height = EditorGUIUtility.singleLineHeight;
            SerializedProperty element = inputs.GetArrayElementAtIndex(index);
            SerializedProperty type    = element.FindPropertyRelative("type");

            EditorGUI.PropertyField(rect, element.FindPropertyRelative("buttonName"), new GUIContent("Name"));
            rect.y += FieldHeight;
            EditorGUI.PropertyField(rect, type, new GUIContent("Type"));
            rect.y += FieldHeight;
            if (type.enumValueIndex != 2)
            {
                EditorGUI.PropertyField(rect, element.FindPropertyRelative("inputName"), new GUIContent("Input Name"));
            }
            else
            {
                GoldPlayerUIHelper.DrawCustomVector2Field(rect,
                                                          element.FindPropertyRelative("inputName"),
                                                          element.FindPropertyRelative("inputNameSecondary"),
                                                          10, new GUIContent("Vector2 Input Name"), false,
                                                          new GUIContent("X", "The input action that will serve the X axis."),
                                                          new GUIContent("Y", "The input action that will serve the Y axis."));
            }

            rect.y += FieldHeight;

            if (type.enumValueIndex == 0 && useKeyCodes.boolValue)
            {
                EditorGUI.PropertyField(rect, element.FindPropertyRelative("key"));
            }
        }
Exemple #2
0
        private void PopupField(SerializedProperty property)
        {
            Rect rect = EditorGUILayout.GetControlRect();

            rect.width = EditorGUIUtility.labelWidth;

            EditorGUI.PrefixLabel(rect, new GUIContent(property.displayName), property.prefabOverride ? EditorStyles.boldLabel : GUI.skin.label);

            rect.width = EditorGUIUtility.singleLineHeight;
            rect.x     = EditorGUIUtility.labelWidth + EditorGUIUtility.singleLineHeight;

            EditorGUI.PropertyField(rect, property.FindPropertyRelative("enabled"), GUIContent.none);

            rect.width = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - (EditorGUIUtility.singleLineHeight * 2) - 5;
            rect.x     = EditorGUIUtility.labelWidth + (EditorGUIUtility.singleLineHeight * 2);

            bool oEnabled = GUI.enabled;

            if (GoldPlayerUIHelper.ShouldDisableElements(property.FindPropertyRelative("enabled")))
            {
                GUI.enabled = false;
            }

            EditorGUI.IntPopup(rect, property.FindPropertyRelative("index"), parameters, optionValues, GUIContent.none);
            GUI.enabled = oEnabled;
        }
Exemple #3
0
        public override VisualElement CreateInspectorGUI()
        {
            VisualElement root = new VisualElement();

#if !OBSOLETE
            root.Add(new PropertyField(isInteractable));
            root.Add(new PropertyField(isHidden));

            root.Add(GoldPlayerUIHelper.GetSpace());

            useCustomMessageElement = new PropertyField(useCustomMessage);
            customMessageElement    = new PropertyField(customMessage);

            useCustomMessageElement.RegisterCallback <ChangeEvent <bool> >((evt) => { customMessageElement.SetEnabled(evt.newValue); });

            customMessageElement.SetEnabled(useCustomMessage.boolValue);

            root.Add(useCustomMessageElement);
            root.Add(customMessageElement);



            root.Add(new PropertyField(onInteract));
#else
            Button removeButton = new Button(() => { Undo.DestroyObjectImmediate((GoldPlayerInteractable)target); })
            {
                text = "Remove Component"
            };
            root.Add(removeButton);
#endif

            return(root);
        }
Exemple #4
0
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            Foldout foldout = new Foldout();

            foldout.BindProperty(property);
            foldout.text = property.displayName;

            foldout.contentContainer.Add(new PropertyField(property.FindPropertyRelative("enableFOVKick")));
            foldout.contentContainer.Add(new PropertyField(property.FindPropertyRelative("unscaledTime")));
            foldout.contentContainer.Add(new PropertyField(property.FindPropertyRelative("kickWhen")));
            foldout.contentContainer.Add(new PropertyField(property.FindPropertyRelative("kickAmount")));
            foldout.contentContainer.Add(new PropertyField(property.FindPropertyRelative("lerpTimeTo")));
            foldout.contentContainer.Add(new PropertyField(property.FindPropertyRelative("lerpTimeFrom")));

            foldout.contentContainer.Add(GoldPlayerUIHelper.GetSpace());

            PropertyField targetCamera = new PropertyField(property.FindPropertyRelative("targetCamera"));

#if GOLD_PLAYER_CINEMACHINE
            PropertyField cineToggle = new PropertyField(property.FindPropertyRelative("useCinemachine"));
            PropertyField cineCamera = new PropertyField(property.FindPropertyRelative("targetVirtualCamera"));

            // Put the register value changed in GeometryChangedEvent because then the property will have been rebuilt.
            cineToggle.RegisterCallback <GeometryChangedEvent>(evt =>
            {
                cineToggle.Q <Toggle>().RegisterValueChangedCallback(x =>
                {
                    targetCamera.style.display = x.newValue ? DisplayStyle.None : DisplayStyle.Flex;
                    cineCamera.style.display   = x.newValue ? DisplayStyle.Flex : DisplayStyle.None;
                });
            });

            bool useCinemachine = property.FindPropertyRelative("useCinemachine").boolValue;
            targetCamera.style.display = useCinemachine ? DisplayStyle.None : DisplayStyle.Flex;
            cineCamera.style.display   = useCinemachine ? DisplayStyle.Flex : DisplayStyle.None;

            foldout.contentContainer.Add(cineToggle);
            foldout.contentContainer.Add(cineCamera);
#endif
            foldout.contentContainer.Add(targetCamera);


            return(foldout);
        }
Exemple #5
0
        public override VisualElement CreateInspectorGUI()
        {
            VisualElement root = new VisualElement()
            {
                name = "Root"
            };

            //PropertyField animatorField = new PropertyField(animator);
            ObjectField animatorField = new ObjectField(animator.displayName)
            {
                objectType = typeof(Animator)
            };

            animatorField.BindProperty(animator);
            animatorField.RegisterValueChangedCallback(x =>
            {
                ToggleParameters(x.newValue != null);
                GetAnimatorParameters(x.newValue);
            });

            moveXField     = GetParameterField(moveX);
            moveYField     = GetParameterField(moveY);
            crouchingField = GetParameterField(crouching);
            lookAngleField = GetParameterField(lookAngle);

            root.Add(animatorField);
            root.Add(new PropertyField(maxSpeed));
            root.Add(new PropertyField(valueSmoothTime));
            root.Add(new PropertyField(lookAngleHead));

            root.Add(GoldPlayerUIHelper.GetSpace());

            root.Add(GoldPlayerUIHelper.GetHeaderLabel("Parameters"));

            root.Add(moveXField);
            root.Add(moveYField);
            root.Add(crouchingField);
            root.Add(lookAngleField);

            ToggleParameters(animator.objectReferenceValue != null);

            return(root);
        }
Exemple #6
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            position.height = EditorGUIUtility.singleLineHeight;
            EditorGUI.PropertyField(position, property);
            if (property.isExpanded)
            {
                EditorGUI.indentLevel++;
                position = DrawNextProperty(position, property.FindPropertyRelative("enableBob"));
                GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("enableBob"), () =>
                {
                    position = DrawNextProperty(position, property.FindPropertyRelative("unscaledTime"));

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("bobFrequency"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("bobHeight"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("swayAngle"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("sideMovement"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("heightMultiplier"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("strideMultiplier"));

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("landMove"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("landTilt"));

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("enableStrafeTilting"));
                    GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("enableStrafeTilting"), () =>
                    {
                        position = DrawNextProperty(position, property.FindPropertyRelative("strafeTilt"));
                    });

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("bobTarget"));
                });
                EditorGUI.indentLevel--;
            }
        }
Exemple #7
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;

            if (property.isExpanded)
            {
                height += GetFieldHeight();

                if (GoldPlayerUIHelper.ShouldShowElements(property.FindPropertyRelative("enableBob")))
                {
                    height += (GetFieldHeight() * 11) + (SPACE_HEIGHT * 4);

                    if (GoldPlayerUIHelper.ShouldShowElements(property.FindPropertyRelative("enableStrafeTilting")))
                    {
                        height += GetFieldHeight();
                    }
                }
            }

            return(height);
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Set 'doGUI' to true as we want to bae it of the GUI.
            doGUI = true;
            // Begin the property GUI.
            EditorGUI.BeginProperty(position, label, property);
            // Set the full rect to the provided position.
            fullRect = position;
            // Set the full rect height to the line height.
            fullRect.height = lineHeight;
            // Set the field rect to the provided position.
            fieldRect = position;
            // Set the field rect height to the line height.
            fieldRect.height = lineHeight;
            // The property foldout.
            EditorGUI.PropertyField(fieldRect, property, label, false);
            // Only draw the rest if the property is expanded.
            if (property.isExpanded)
            {
                //Indent the GUI one step.
                EditorGUI.indentLevel++;
                // Add to the rect.
                AddToRect();
                // The 'Enabled' field.
                EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("enabled"));

                GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("enabled"), () =>
                {
                    // Add to the rect.
                    AddToRect();
                    // The 'Random Pitch' field.
                    EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("randomPitch"));
                    // Add to the rect.
                    AddToRect();
                    // If random pitch is enabled, draw min max fields.
                    // Else just draw one field.
                    if (property.FindPropertyRelative("randomPitch").boolValue)
                    {
                        GoldPlayerUIHelper.DrawCustomVector2Field(fieldRect,
                                                                  property.FindPropertyRelative("minPitch"),
                                                                  property.FindPropertyRelative("maxPitch"),
                                                                  30, new GUIContent("Pitch"), true, new GUIContent("Min"), new GUIContent("Max"));
                    }
                    else
                    {
                        // The 'Pitch' field.
                        EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("pitch"));
                    }
                    // Add to the rect.
                    AddToRect();
                    // The 'Change Volume' field.
                    EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("changeVolume"));
                    // If change volume is true, draw the volume field.
                    GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("changeVolume"), () =>
                    {
                        // Add to the rect.
                        AddToRect();
                        // The volume slider field.
                        EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("volume"));
                    });
                    // Add to the rect.
                    AddToRect();
                    // The audio clips array.
                    EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("audioClips"), true);
                    // If the audio clips array is expanded, add to the rect to make sure everything is shown.
                    if (property.FindPropertyRelative("audioClips").isExpanded)
                    {
                        // Add a rect for the size field.
                        AddToRect();
                        // For every clip, add a size for every field.
                        for (int i = 0; i < property.FindPropertyRelative("audioClips").arraySize; i++)
                        {
                            AddToRect();
                        }
                    }
                });

                // Remove the indent.
                EditorGUI.indentLevel--;
            }
            // End the property GUI.
            EditorGUI.EndProperty();
        }