コード例 #1
0
 /// <summary>
 ///     Draws the content.
 /// </summary>
 /// <param name="position">Position.</param>
 protected override void DrawContent(Rect position)
 {
     HydraEditorUtils.DrawUnindented(
         () =>
         HydraEditorUtils.EnumPopupField <MouseButtonInputAttribute.Buttons>(position, GUIContent.none, m_InputProperty,
                                                                             HydraEditorGUIStyles.enumStyle));
 }
コード例 #2
0
        /// <summary>
        ///     Draws the content.
        /// </summary>
        /// <param name="position">Position.</param>
        /// <param name="locked">Locked.</param>
        protected override void DrawContent(Rect position, bool locked)
        {
            HydraEditorUtils.DrawUnindented(
                () => GUI.Box(position, GUIContent.none, HydraEditorGUIStyles.vector3CurvesBackgroundStyle));

            // Draw the curves
            Rect curvesBounds = GetCurvesBoundingRect();

            if (locked)
            {
                DrawCurveSwatch(position, m_CurveXProperty, s_LockedColor, curvesBounds);

                m_CurveYProperty.animationCurveValue = m_CurveXProperty.animationCurveValue;
                m_CurveZProperty.animationCurveValue = m_CurveXProperty.animationCurveValue;
            }
            else
            {
                DrawCurveSwatch(position, m_CurveXProperty, s_ColorX, curvesBounds);
                DrawCurveSwatch(position, m_CurveYProperty, s_ColorY, curvesBounds);
                DrawCurveSwatch(position, m_CurveZProperty, s_ColorZ, curvesBounds);
            }

            // Draw the foreground button
            DrawForegroundButton(position, locked);
        }
コード例 #3
0
        /// <summary>
        ///     Draws the foreground button.
        /// </summary>
        /// <param name="position">Position.</param>
        /// <param name="locked">Locked.</param>
        private void DrawForegroundButton(Rect position, bool locked)
        {
            string name = m_CurveXProperty.GetHashCode().ToString();

            GUI.SetNextControlName(name);

            bool pressed =
                HydraEditorUtils.DrawUnindented(
                    () => GUI.Button(position, GUIContent.none, HydraEditorGUIStyles.vector3CurvesForegroundStyle));

            if (!pressed)
            {
                return;
            }

            GUI.FocusControl(name);

            Vector3CurvesAttribute parent = m_CurveXProperty.GetParent() as Vector3CurvesAttribute;

            if (locked)
            {
                EditCurve(parent.curveX, "Edit XYZ", s_LockedColor);
            }
            else
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Edit X"), false, () => EditCurve(parent.curveX, "Edit X", s_ColorX));
                menu.AddItem(new GUIContent("Edit Y"), false, () => EditCurve(parent.curveY, "Edit Y", s_ColorY));
                menu.AddItem(new GUIContent("Edit Z"), false, () => EditCurve(parent.curveZ, "Edit Z", s_ColorZ));

                menu.ShowAsContext();
            }
        }
コード例 #4
0
        /// <summary>
        ///     Override this method to make your own GUI for the property
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="prop">Property</param>
        /// <param name="label">Label</param>
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, prop);

            FindProperties(prop);

            position.height = EditorGUIUtility.singleLineHeight;
            position        = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            // Draw the lock
            Rect lockPosition = new Rect(position);

            lockPosition.width = lockPosition.height;
            HydraEditorUtils.DrawUnindented(() => LockField(lockPosition, m_LockedProperty));

            // Draw the contents
            Rect  contentPosition = new Rect(position);
            float offset          = lockPosition.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING;

            contentPosition.x     += offset;
            contentPosition.width -= offset;

            DrawContent(contentPosition, m_LockedProperty.boolValue);

            EditorGUI.EndProperty();
        }
コード例 #5
0
        /// <summary>
        ///     Draws the tangents.
        /// </summary>
        private void DrawTangents(Rect position)
        {
            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field2Dp(position, s_InLabel, m_InTangentProp));

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field2Dp(position, s_OutLabel, m_OutTangentProp));
        }
コード例 #6
0
        /// <summary>
        ///     Raises when Random Between Two Constants has been selected.
        /// </summary>
        /// <param name="position">Position.</param>
        private void OnRandomBetweenTwoConstants(Rect position)
        {
            Rect gradientRect = new Rect(position);

            gradientRect.width = (position.width - HydraEditorUtils.STANDARD_HORIZONTAL_SPACING) / 2.0f;
            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueAProperty, GUIContent.none));

            gradientRect.x += gradientRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING;
            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueBProperty, GUIContent.none));
        }
コード例 #7
0
        /// <summary>
        ///     Raises when Gradient has been selected.
        /// </summary>
        /// <param name="position">Position.</param>
        private void OnGradient(Rect position)
        {
            HydraEditorUtils.DrawUnindented(() => GradientWrapField(position));

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            HydraEditorUtils.DrawUnindented(
                () => EditorGUI.PropertyField(position, m_GradientLengthProperty, s_GradientLengthLabel));

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_GradientAProperty, GUIContent.none));
        }
コード例 #8
0
        /// <summary>
        ///     Draws the content.
        /// </summary>
        /// <param name="position">Position.</param>
        /// <param name="locked">Locked.</param>
        protected override void DrawContent(Rect position, bool locked)
        {
            if (locked)
            {
                HydraEditorUtils.DrawUnindented(
                    () => HydraEditorUtils.UniformVector3Field(position, GUIContent.none, m_VectorProperty));
                return;
            }

            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field(position, GUIContent.none, m_VectorProperty));
        }
コード例 #9
0
        /// <summary>
        ///     Raises when Random Between Two Curves has been selected.
        /// </summary>
        /// <param name="position">Position.</param>
        private void OnRandomBetweenTwoCurves(Rect position)
        {
            position.height = EditorGUIUtility.singleLineHeight;

            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_LinearLabel, m_LinearProperty));

            Rect vector3Rect = new Rect(position);

            vector3Rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(vector3Rect, m_CurvesAProperty, GUIContent.none));

            vector3Rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(vector3Rect, m_CurvesBProperty, GUIContent.none));
        }
コード例 #10
0
        /// <summary>
        ///     Override this method to make your own GUI for the property
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="prop">Property</param>
        /// <param name="label">Label</param>
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, prop);

            FindProperties(prop);

            position.height = EditorGUIUtility.singleLineHeight;
            position        = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            // Range Mode
            Rect rangeModePosition = new Rect(position);

            rangeModePosition.x    += (rangeModePosition.width - 12);
            rangeModePosition.width = 12;

            HydraEditorUtils.DrawUnindented(
                () =>
                HydraEditorUtils.EnumPopupField <Vector3RangeAttribute.RangeMode>(rangeModePosition, GUIContent.none,
                                                                                  m_RangeModeProperty, HydraEditorGUIStyles.enumStyle));

            // Range Mode Fields
            Rect rangeModeFieldsPosition = new Rect(position);

            rangeModeFieldsPosition.width -= (rangeModePosition.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING);

            switch (m_RangeModeProperty.GetEnumValue <Vector3RangeAttribute.RangeMode>())
            {
            case Vector3RangeAttribute.RangeMode.Constant:
                OnConstant(rangeModeFieldsPosition);
                break;

            case Vector3RangeAttribute.RangeMode.CurveSet:
                OnCurve(rangeModeFieldsPosition);
                break;

            case Vector3RangeAttribute.RangeMode.RandomBetweenTwoConstants:
                OnRandomBetweenTwoConstants(rangeModeFieldsPosition);
                break;

            case Vector3RangeAttribute.RangeMode.RandomBetweenTwoCurveSets:
                OnRandomBetweenTwoCurves(rangeModeFieldsPosition);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            EditorGUI.EndProperty();
        }
コード例 #11
0
        /// <summary>
        ///     Override this method to make your own GUI for the property
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="prop">Property</param>
        /// <param name="label">Label</param>
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, prop);

            FindProperties(prop);

            position.height = EditorGUIUtility.singleLineHeight;
            position        = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            float oldLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = LABEL_WIDTH;

            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field2Dp(position, s_PositionLabel, m_PositionProp));

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            HydraEditorUtils.DrawUnindented(
                () =>
                HydraEditorUtils.EnumPopupField <TangentMode>(position, s_SmoothingLabel, m_TangentModeProp,
                                                              HydraEditorGUIStyles.enumStyle));

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            switch (m_TangentModeProp.GetEnumValue <TangentMode>())
            {
            case TangentMode.Auto:
                break;

            case TangentMode.Corner:
                DrawTangents(position);
                break;

            case TangentMode.Smooth:
                DrawTangents(position);
                break;

            case TangentMode.Symmetric:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            EditorGUIUtility.labelWidth = oldLabelWidth;

            EditorGUI.EndProperty();
        }
コード例 #12
0
        /// <summary>
        ///     Raises when Random Between Two Constants has been selected.
        /// </summary>
        /// <param name="position">Position.</param>
        private void OnRandomBetweenTwoConstants(Rect position)
        {
            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_LinearLabel, m_LinearProperty));

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            HydraEditorUtils.DrawUnindented(() => RandomBlendField(position));

            Rect gradientRect = new Rect(position);

            gradientRect.y    += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            gradientRect.width = (gradientRect.width - HydraEditorUtils.STANDARD_HORIZONTAL_SPACING) / 2.0f;
            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueAProperty, GUIContent.none));

            gradientRect.x += gradientRect.width;
            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueBProperty, GUIContent.none));
        }
コード例 #13
0
        /// <summary>
        ///     Override this method to make your own GUI for the property
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="prop">Property</param>
        /// <param name="label">Label</param>
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, prop);

            FindProperties(prop);

            position.height = EditorGUIUtility.singleLineHeight;
            position        = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            HydraEditorUtils.DrawUnindented(
                () =>
                HydraEditorUtils.EnumPopupField <ColorRangeAttribute.RangeMode>(position, GUIContent.none, m_RangeModeProperty,
                                                                                HydraEditorGUIStyles.enumStyle));

            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            switch (m_RangeModeProperty.GetEnumValue <ColorRangeAttribute.RangeMode>())
            {
            case ColorRangeAttribute.RangeMode.Constant:
                OnConstant(position);
                break;

            case ColorRangeAttribute.RangeMode.Gradient:
                OnGradient(position);
                break;

            case ColorRangeAttribute.RangeMode.RandomInGradient:
                OnRandomInGradient(position);
                break;

            case ColorRangeAttribute.RangeMode.RandomBetweenTwoConstants:
                OnRandomBetweenTwoConstants(position);
                break;

            case ColorRangeAttribute.RangeMode.RandomBetweenTwoGradients:
                OnRandomBetweenTwoGradients(position);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            EditorGUI.EndProperty();
        }
コード例 #14
0
        /// <summary>
        ///     Override this method to make your own GUI for the property
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="prop">Property</param>
        /// <param name="label">Label</param>
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, prop);

            FindProperties(prop);

            position.height = EditorGUIUtility.singleLineHeight;
            position        = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            position.width = HORIZONTAL_SPACING;

            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_XLabel, m_XProperty));

            position.x += HORIZONTAL_SPACING;
            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_YLabel, m_YProperty));

            position.x += HORIZONTAL_SPACING;
            HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_ZLabel, m_ZProperty));

            EditorGUI.EndProperty();
        }
コード例 #15
0
        /// <summary>
        ///     Override this method to make your own GUI for the property
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="prop">Property</param>
        /// <param name="label">Label</param>
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, prop);

            position.height = EditorGUIUtility.singleLineHeight;
            Rect contents = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            FindProperties(prop);

            // Draw the preview texture
            Rect textureRect = new Rect(contents);

            textureRect.x     += textureRect.width - PREVIEW_TEXTURE_SIZE;
            textureRect.width  = PREVIEW_TEXTURE_SIZE;
            textureRect.height = PREVIEW_TEXTURE_SIZE;

            EditorGUI.BeginChangeCheck();

            HydraEditorUtils.DrawUnindented(
                () => HydraEditorUtils.TextureField(textureRect, GUIContent.none, m_TextureProp, true));

            // Draw the fields
            Rect contentRect = new Rect(contents);

            contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f;
            HydraEditorUtils.DrawUnindented(
                () =>
                HydraEditorUtils.EnumPopupField <Texture2DAttribute.Wrap>(contentRect, GUIContent.none, m_WrapProp,
                                                                          HydraEditorGUIStyles.enumStyle));

            // Clear the cache if the texture changes
            if (EditorGUI.EndChangeCheck())
            {
                m_WrappedTextureProp.objectReferenceValue = null;
            }

            EditorGUI.EndProperty();
        }
コード例 #16
0
 /// <summary>
 ///     Draws the content.
 /// </summary>
 /// <param name="position">Position.</param>
 protected override void DrawContent(Rect position)
 {
     HydraEditorUtils.DrawUnindented(
         () =>
         HydraEditorUtils.AxisInputField(position, GUIContent.none, m_InputProperty, HydraEditorGUIStyles.enumStyle));
 }
コード例 #17
0
 /// <summary>
 ///     Raises when constant has been selected.
 /// </summary>
 /// <param name="position">Position.</param>
 private void OnConstant(Rect position)
 {
     HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_ConstValueAProperty, GUIContent.none));
 }
コード例 #18
0
 /// <summary>
 ///     Raises when Random In Gradient has been selected.
 /// </summary>
 /// <param name="position">Position.</param>
 private void OnRandomInGradient(Rect position)
 {
     HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_GradientAProperty, GUIContent.none));
 }
コード例 #19
0
        /// <summary>
        ///     Raises when curve has been selected.
        /// </summary>
        /// <param name="position">Position.</param>
        private void OnCurve(Rect position)
        {
            position.height = EditorGUIUtility.singleLineHeight;

            HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_CurvesAProperty, GUIContent.none));
        }