Exemplo n.º 1
0
 bool IsStrokeRenderTypeCameraDependent(StrokeRenderType strokeRenderType)
 {
     if (strokeRenderType == StrokeRenderType.ShapeSpace)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
    public static void DrawStrokeEditor(Shape shape)
    {
        bool              newDrawStroke       = shape.ShapeData.IsStrokeEnabled;
        float             newMiterLimit       = shape.ShapeData.StrokeMiterLimit;
        StrokeRenderType  renderType          = shape.ShapeData.StrokeRenderType;
        StrokeTextureType strokeTextureType   = shape.ShapeData.StrokeTextureType;
        float             textureTiling       = shape.ShapeData.StrokeTextureTiling;
        float             textureOffset       = shape.ShapeData.StrokeTextureOffset;
        bool              variableStrokeWidth = shape.ShapeData.HasVariableStrokeWidth;
        bool              variableStrokeColor = shape.ShapeData.HasVariableStrokeColor;
        StrokeCornerType  newCornerType       = shape.ShapeData.StrokeCornerType;
        Color             strokeColor         = shape.ShapeData.GetStrokeColor();

        if (variableStrokeColor && shape.ShapeData.GetPolyPointCount() > 0)
        {
            strokeColor = shape.ShapeData.GetPolyStrokeColor(0);
        }

        float strokeWidth = shape.ShapeData.GetStrokeWidth();

        if (variableStrokeWidth && shape.ShapeData.GetPolyPointCount() > 0)
        {
            strokeWidth = shape.ShapeData.GetPolyStrokeWidth(0);
        }

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.Space();
        GUILayout.Label("Stroke", EditorStyles.boldLabel);
        EditorGUI.indentLevel++;

        newDrawStroke = EditorGUILayout.Toggle("Draw Stroke", newDrawStroke);
        if (newDrawStroke)
        {
            newMiterLimit       = EditorGUILayout.FloatField("Miter Limit", newMiterLimit);
            renderType          = (StrokeRenderType)EditorGUILayout.EnumPopup("Render Type", renderType);
            newCornerType       = (StrokeCornerType)EditorGUILayout.EnumPopup("Corner Type", newCornerType);
            variableStrokeColor = false;
            //uniformStrokeColor = EditorGUILayout.Toggle("Variable Stroke Color", uniformStrokeColor);
            if (!variableStrokeColor)
            {
                //	EditorGUI.indentLevel++;
                strokeColor = EditorGUILayout.ColorField("Stroke Color", strokeColor);
                //	EditorGUI.indentLevel--;
            }
            variableStrokeWidth = EditorGUILayout.Toggle("Variable Stroke Width", variableStrokeWidth);
            if (!variableStrokeWidth)
            {
                //EditorGUI.indentLevel++;
                strokeWidth = EditorGUILayout.FloatField("Stroke Width", strokeWidth);
                //EditorGUI.indentLevel--;
            }
            textureTiling     = EditorGUILayout.FloatField("Texture Tiling", textureTiling);
            textureOffset     = EditorGUILayout.FloatField("Texture Offset", textureOffset);
            strokeTextureType = (StrokeTextureType)EditorGUILayout.EnumPopup("Texture Type", strokeTextureType);
        }

        EditorGUI.indentLevel--;

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(shape.dataContainerObject, "Edit Stroke");
            shape.ShapeData.IsStrokeEnabled        = newDrawStroke;
            shape.ShapeData.StrokeMiterLimit       = Mathf.Max(1, newMiterLimit);
            shape.ShapeData.StrokeCornerType       = newCornerType;
            shape.ShapeData.HasVariableStrokeColor = variableStrokeColor;
            shape.ShapeData.HasVariableStrokeWidth = variableStrokeWidth;
            shape.ShapeData.StrokeRenderType       = renderType;
            shape.ShapeData.StrokeTextureTiling    = textureTiling;
            shape.ShapeData.StrokeTextureOffset    = textureOffset;
            shape.ShapeData.StrokeTextureType      = strokeTextureType;
            if (!variableStrokeColor)
            {
                shape.ShapeData.SetStrokeColor(strokeColor);
            }
            if (!variableStrokeWidth)
            {
                strokeWidth = Mathf.Max(0, strokeWidth);
                shape.ShapeData.SetStrokeWidth(strokeWidth);
            }

            SetDataDirty(shape);
        }
    }