public void SetPathType(PATHTYPE pt)
    {
        switch (pt)
        {
        case PATHTYPE.POLY_LINE:
            displayMethod = PATHTYPE.POLY_LINE;
            path          = lp;
            break;

        case PATHTYPE.CATMULLROM_SPLINE:
            displayMethod = PATHTYPE.CATMULLROM_SPLINE;
            path          = crsp;
            break;

        default:
            path          = lp;
            displayMethod = PATHTYPE.POLY_LINE;
            break;
        }
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        if (PathManager == null)
        {
            return;
        }
        EditorGUILayout.BeginVertical();
        pathType = (PATHTYPE)EditorGUILayout.EnumPopup("Display:", PathManager.displayMethod);
        if (pathType != prevPathType)
        {
            switch (pathType)
            {
            case PATHTYPE.POLY_LINE:
                path = lp;
                break;

            case PATHTYPE.CATMULLROM_SPLINE:
                path = crsp;
                break;

            default:
                path = lp;
                break;
            }
            PathManager.SetPathType(pathType);
            prevPathType = pathType;
        }
        path.SetPathManager(PathManager);
        EditorGUILayout.PrefixLabel("Minimum Height");
        minht = EditorGUILayout.TextField(minht, GUILayout.ExpandWidth(false));
        if (minht.CompareTo(oldminht) != 0)
        {
            float fval;
            if (float.TryParse(minht, out fval))
            {
                PathManager.minHeight = fval;
            }
            oldminht = minht;
        }

        EditorGUILayout.PrefixLabel("Tool Color");
        PathManager.lineColor = EditorGUILayout.ColorField(PathManager.lineColor, GUILayout.ExpandWidth(false));

        if (GUILayout.Button("Duplicate Endpoints"))
        {
            PathManager.DuplicateEndPoints();
        }

        if (GUILayout.Button("Add New Point"))
        {
            PathManager.AddNewPoint();
        }
        int i = 0;

        foreach (Vector3 v in PathManager.points)
        {
            EditorGUILayout.Vector3Field(i.ToString(), v);
            i++;
        }
        if (GUILayout.Button("Remove All Points"))
        {
            PathManager.RemoveAllPoints();
        }
        GUILayout.BeginHorizontal("box");
        pointtoremove = GUILayout.TextField(pointtoremove, 25);
        if (GUILayout.Button("Remove Point " + pointtoremove))
        {
            int val = -1;
            if (int.TryParse(pointtoremove, out val))
            {
                if (val >= 0 && val < PathManager.points.Count)
                {
                    PathManager.RemovePoint(val);
                }
            }
        }
        GUILayout.EndHorizontal();


        EditorGUILayout.EndVertical();
        if (GUI.changed)
        {
            EditorUtility.SetDirty(PathManager);
        }
    }
示例#3
0
 PathManagerEditor()
 {
     pathType     = PATHTYPE.CATMULLROM_SPLINE;
     prevPathType = PATHTYPE.CATMULLROM_SPLINE;
     path         = crsp;
 }