Exemplo n.º 1
0
    private void Awake()
    {
        // Initializing
        curve = (BezierCubic)target;
        if (curve.ControlPoints == null)
        {
            curve.ResetToTemplate(Vector3.zero);
        }

        // Setting default settings
        SetDefaultDisplayMetrics();
        SetDefaultColors();
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();
        if (GUI.changed)
        {
            // Update lineRenderer
            UpdateLineRenderer(IterationMode.Linear, curve.s_curveResolution);
        }

        if (curve == null)
        {
            curve = (BezierCubic)target;
        }
        SetToggleButtonStyles();

        // Instructions foldout (may be redundant - consider removing based on user editing controls)
        if (GUILayout.Button("Edit Curve", isEditing == true ? ToggleButtonStyleOn : ToggleButtonStyleOff))
        {
            isEditing = !isEditing;
            Debug.Log("Clicked Edit Curve!");
        }
        addMode = (AddMode)EditorGUILayout.EnumPopup("Add Mode: ", addMode);
        GUILayout.Space(5);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Undo"))
        {
            Debug.Log("Clicked Undo!");
        }
        if (GUILayout.Button("Redo"))
        {
            Debug.Log("Clicked Redo!");
        }
        GUILayout.EndHorizontal();

        #region Display Settings
        expandDisplaySettings = EditorGUILayout.Foldout(expandDisplaySettings, "Display Settings");
        if (expandDisplaySettings == true)
        {
            EditorGUI.indentLevel++;

            // Display metrics
            expandDisplaySettingsMetric = EditorGUILayout.Foldout(expandDisplaySettingsMetric, "Display Metrics");
            if (expandDisplaySettingsMetric == true)
            {
                EditorGUILayout.LabelField("Display resolution");
                EditorGUI.BeginChangeCheck();
                curve.s_curveResolution = EditorGUILayout.IntSlider("Curve Resolution", curve.s_curveResolution, 1, 100);
                EditorGUI.EndChangeCheck();
                EditorGUILayout.LabelField("Control Point Radii");
                curve.s_handlePointRadiusFixed   = EditorGUILayout.Toggle("Enforce Uniform Radii", curve.s_handlePointRadiusFixed);
                curve.s_handlePointUniformRadius = EditorGUILayout.FloatField("Uniform Radius", curve.s_handlePointUniformRadius);
                EditorGUILayout.Space();
                curve.s_handlePointAnchorRadius = EditorGUILayout.FloatField("Anchor Point Radius", curve.s_handlePointAnchorRadius);
                curve.s_handlePointAnchorDiscontinuousRadius = EditorGUILayout.FloatField("Broken Anchor Point Radius", curve.s_handlePointAnchorDiscontinuousRadius);
                curve.s_handlePointHandleRadius = EditorGUILayout.FloatField("Handle Point Radius", curve.s_handlePointHandleRadius);
                EditorGUILayout.LabelField("Widths");
                curve.s_displayWidthFixed   = EditorGUILayout.Toggle("Enforce Uniform Widths", curve.s_displayWidthFixed);
                curve.s_displayWidthUniform = EditorGUILayout.FloatField("Uniform Width", curve.s_displayWidthUniform);
                EditorGUILayout.Space();
                curve.s_displayWidthCurve     = EditorGUILayout.FloatField("Curve Width", curve.s_displayWidthCurve);
                curve.s_displayWidthTangent   = EditorGUILayout.FloatField("Tangent Width", curve.s_displayWidthTangent);
                curve.s_displayWidthNormal    = EditorGUILayout.FloatField("Normal Width", curve.s_displayWidthNormal);
                curve.s_displayWidthBitangent = EditorGUILayout.FloatField("Bitangent Width", curve.s_displayWidthBitangent);
                EditorGUILayout.LabelField("Lengths");
                curve.s_displayLengthFixed   = EditorGUILayout.Toggle("Enforce Uniform Lengths", curve.s_displayLengthFixed);
                curve.s_displayLengthUniform = EditorGUILayout.FloatField("Uniform Length", curve.s_displayLengthUniform);
                EditorGUILayout.Space();
                curve.s_displayLengthTangent   = EditorGUILayout.FloatField("Tangent Length", curve.s_displayLengthTangent);
                curve.s_displayLengthNormal    = EditorGUILayout.FloatField("Normal Length", curve.s_displayLengthNormal);
                curve.s_displayLengthBitangent = EditorGUILayout.FloatField("Bitangent Length", curve.s_displayLengthBitangent);
            }

            // Colors
            expandDisplaySettingsColor = EditorGUILayout.Foldout(expandDisplaySettingsColor, "Colors");
            if (expandDisplaySettingsColor == true)
            {
                EditorGUILayout.LabelField("Curve Colors");
                curve.s_colorCurveDefault  = EditorGUILayout.ColorField("Curve Default", curve.s_colorCurveDefault);
                curve.s_colorCurveHover    = EditorGUILayout.ColorField("Curve Hover", curve.s_colorCurveHover);
                curve.s_colorCurveClick    = EditorGUILayout.ColorField("Curve Clicked", curve.s_colorCurveClick);
                curve.s_colorCurveDisabled = EditorGUILayout.ColorField("Curve Disabled", curve.s_colorCurveDisabled);
                EditorGUILayout.LabelField("Tangent Colors");
                curve.s_colorTangentDefault  = EditorGUILayout.ColorField("Tangent Default", curve.s_colorTangentDefault);
                curve.s_colorTangentHover    = EditorGUILayout.ColorField("Tangent Hover", curve.s_colorTangentHover);
                curve.s_colorTangentClick    = EditorGUILayout.ColorField("Tangent Clicked", curve.s_colorTangentClick);
                curve.s_colorTangentDisabled = EditorGUILayout.ColorField("Tangent Disabled", curve.s_colorTangentDisabled);
                EditorGUILayout.LabelField("Normal Colors");
                curve.s_colorNormalDefault  = EditorGUILayout.ColorField("Normal Default", curve.s_colorNormalDefault);
                curve.s_colorNormalHover    = EditorGUILayout.ColorField("Normal Hover", curve.s_colorNormalHover);
                curve.s_colorNormalClick    = EditorGUILayout.ColorField("Normal Clicked", curve.s_colorNormalClick);
                curve.s_colorNormalDisabled = EditorGUILayout.ColorField("Normal Disabled", curve.s_colorNormalDisabled);
                EditorGUILayout.LabelField("Bitangent Colors");
                curve.s_colorBitangentDefault  = EditorGUILayout.ColorField("Bitangent Default", curve.s_colorBitangentDefault);
                curve.s_colorBitangentHover    = EditorGUILayout.ColorField("Bitangent Hover", curve.s_colorBitangentHover);
                curve.s_colorBitangentClick    = EditorGUILayout.ColorField("Bitangent Clicked", curve.s_colorBitangentClick);
                curve.s_colorBitangentDisabled = EditorGUILayout.ColorField("Bitangent Disabled", curve.s_colorBitangentDisabled);
                EditorGUILayout.LabelField("Anchor Point Colors");
                curve.s_colorPointAnchorDefault  = EditorGUILayout.ColorField("Anchor Point Default", curve.s_colorPointAnchorDefault);
                curve.s_colorPointAnchorHover    = EditorGUILayout.ColorField("Anchor Point Hover", curve.s_colorPointAnchorHover);
                curve.s_colorPointAnchorClick    = EditorGUILayout.ColorField("Anchor Point Clicked", curve.s_colorPointAnchorClick);
                curve.s_colorPointAnchorDisabled = EditorGUILayout.ColorField("Anchor Point Default", curve.s_colorPointAnchorDisabled);
                EditorGUILayout.LabelField("Broken Anchor Point Colors");
                curve.s_colorPointAnchorDiscontinuousDefault  = EditorGUILayout.ColorField("Broken Anchor Point Default", curve.s_colorPointAnchorDiscontinuousDefault);
                curve.s_colorPointAnchorDiscontinuousHover    = EditorGUILayout.ColorField("Broken Anchor Point Hover", curve.s_colorPointAnchorDiscontinuousHover);
                curve.s_colorPointAnchorDiscontinuousClick    = EditorGUILayout.ColorField("Broken Anchor Point Clicked", curve.s_colorPointAnchorDiscontinuousClick);
                curve.s_colorPointAnchorDiscontinuousDisabled = EditorGUILayout.ColorField("Broken Anchor Point Default", curve.s_colorPointAnchorDiscontinuousDisabled);
                EditorGUILayout.LabelField("Handle Point Colors");
                curve.s_colorPointHandleDefault  = EditorGUILayout.ColorField("Handle Point Default", curve.s_colorPointHandleDefault);
                curve.s_colorPointHandleHover    = EditorGUILayout.ColorField("Handle Point Hover", curve.s_colorPointHandleHover);
                curve.s_colorPointHandleClick    = EditorGUILayout.ColorField("Handle Point Clicked", curve.s_colorPointHandleClick);
                curve.s_colorPointHandleDisabled = EditorGUILayout.ColorField("Handle Point Disabled", curve.s_colorPointHandleDisabled);
                EditorGUILayout.LabelField("Control Polygon Colors");
                curve.s_colorControlPolygon = EditorGUILayout.ColorField("Control Polygon", curve.s_colorControlPolygon);
                curve.s_colorControlHull    = EditorGUILayout.ColorField("Control Convex Hull", curve.s_colorControlHull);
            }

            EditorGUI.indentLevel--;

            // Checking for changes
            if (GUI.changed == true)
            {
                UpdateLineRenderer(IterationMode.Linear, curve.s_curveResolution);
            }
        }
        #endregion

        GUILayout.Space(10);
        // Consider giving red color, hatched pattern, etc. to convey danger
        if (GUILayout.Button("Reset Curve"))
        {
            curve.ResetToTemplate(Vector3.zero);
            UpdateLineRendererDefault();

            SceneView.RepaintAll();
            Debug.Log("Clicked Reset Curve!");
        }
        GUI.backgroundColor = new Color(255 / 255f, 235 / 255f, 235 / 255f, 1.0f);
        if (GUILayout.Button("Remove Component"))
        {
            if (lineRenderer != null)
            {
                DestroyImmediate(lineRenderer);
            }
            DestroyImmediate(curve);

            SceneView.RepaintAll();
            Debug.Log("Clicked Remove Component!");
        }
    }