/// <summary>
        ///     Draws the lock field.
        /// </summary>
        /// <param name="position">Position.</param>
        /// <param name="prop">Property.</param>
        private void LockField(Rect position, SerializedProperty prop)
        {
            Texture2D trueTexture  = EditorResourceCache.GetResource <Texture2D>("HydraCommon", "Textures", PADLOCK_CLOSED_NAME);
            Texture2D falseTexture = EditorResourceCache.GetResource <Texture2D>("HydraCommon", "Textures", PADLOCK_OPEN_NAME);

            HydraEditorUtils.ToggleTexturesField(position, GUIContent.none, prop, trueTexture, falseTexture);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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);

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

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

            DrawPreviewTexture(textureRect);

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

            contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f;
            HydraEditorUtils.Vector3Field(contentRect, s_NoiseFrequencyLabel, m_FrequencyProp);

            contentRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            HydraEditorUtils.Vector3Field(contentRect, s_NoisePhaseLabel, m_PhaseProp);

            EditorGUI.EndProperty();
        }
 /// <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));
 }
Ejemplo n.º 5
0
        /// <summary>
        ///     Called to draw the GUI in scene view.
        /// </summary>
        /// <param name="sceneView">Scene View.</param>
        protected override void OnSceneViewGUI(SceneView sceneView)
        {
            base.OnSceneViewGUI(sceneView);

            Rect cameraRect = sceneView.camera.pixelRect;

            Rect guiRect = new Rect(cameraRect.width - (WIDTH + SCREEN_PADDING_X),
                                    cameraRect.height - (HEIGHT + SCREEN_PADDING_Y), WIDTH, HEIGHT);

            Color backgroundColor = GUI.backgroundColor;

            if (!EditorGUIUtility.isProSkin)
            {
                GUI.backgroundColor = new Color(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0.8f);
            }

            Rect windowRect = GUILayout.Window(s_WindowId, guiRect, DrawWindowContents, GetWindowTitle(),
                                               HydraEditorGUIStyles.windowStyle);

            GUI.backgroundColor = backgroundColor;

            // Correct for the header
            windowRect.y -= 16;
            HydraEditorUtils.EatMouseInput(windowRect, s_WindowId);
        }
Ejemplo n.º 6
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();
            }
        }
        /// <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();
        }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
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));
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 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);

            // 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();
        }
Ejemplo n.º 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);

            HydraEditorUtils.SceneField(position, label, m_GuidProp, HydraEditorGUIStyles.enumStyle);

            string path = AssetDatabase.GUIDToAssetPath(m_GuidProp.stringValue);

            m_NameProp.stringValue = string.IsNullOrEmpty(path) ? string.Empty : EditorSceneUtils.GetSceneName(path);
            m_IndexProp.intValue   = string.IsNullOrEmpty(path) ? 0 : EditorSceneUtils.GetSceneIndex(path);

            EditorGUI.EndProperty();
        }
Ejemplo n.º 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);

            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();
        }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
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();
        }
Ejemplo n.º 18
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();
        }
Ejemplo n.º 19
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();
        }
Ejemplo n.º 20
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));
 }
Ejemplo n.º 21
0
        /// <summary>
        ///     Draws the preview texture.
        /// </summary>
        private void DrawPreviewTexture(Rect position)
        {
            Texture2D texture = GetTexture(m_FrequencyProp, m_PhaseProp);

            HydraEditorUtils.PreviewTexture(position, texture);
        }
Ejemplo n.º 22
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));
 }
Ejemplo n.º 23
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));
        }
Ejemplo n.º 24
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));
 }
Ejemplo n.º 25
0
 /// <summary>
 ///     Draws the random blend field.
 /// </summary>
 /// <param name="position">Position.</param>
 private void RandomBlendField(Rect position)
 {
     HydraEditorUtils.EnumPopupField <ColorUtils.Gamut>(position, s_RandomBlendLabel, m_RandomBlendProperty,
                                                        HydraEditorGUIStyles.enumStyle);
 }
Ejemplo n.º 26
0
 /// <summary>
 ///     Draws the gradient wrap field.
 /// </summary>
 /// <param name="position">Position.</param>
 private void GradientWrapField(Rect position)
 {
     HydraEditorUtils.EnumPopupField <GradientExtensions.GradientWrapMode>(position, s_GradientWrapModeLabel,
                                                                           m_GradientWrapModeProperty, HydraEditorGUIStyles.enumStyle);
 }