Exemplo n.º 1
0
        private void OnSceneGUI()
        {
            if (_autoGenerateRoad == true)
            {
                PathPointEditor.OnSceneUpdate(SceneView.lastActiveSceneView);
            }

            DrawBezierCurve();
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(5.0f);

            EditorGUILayout.BeginHorizontal();
            ShapeAsset shapeAsset = (ShapeAsset)EditorGUILayout.ObjectField(
                "Shape", _currentPath.shapeAsset, typeof(ShapeAsset), false);

            _currentPath.shapeAsset = shapeAsset;

            if (shapeAsset != null)
            {
                if (GUILayout.Button("Edit", GUILayout.Width(60)))
                {
                    ShapeEditorWindow.Edit(shapeAsset);
                }
            }
            else
            {
                if (GUILayout.Button("Create", GUILayout.Width(60)))
                {
                    ShapeAsset newShapeAsset = CreateShapeAsset();
                    if (newShapeAsset != null)
                    {
                        _currentPath.shapeAsset = newShapeAsset;
                    }
                }
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(15);

            EditorGUI.BeginChangeCheck();

            Vector2 scale        = EditorGUILayout.Vector2Field("Scale", _currentPath.scale);
            int     subdivisions = EditorGUILayout.IntField("Subdivisions", Mathf.Clamp(_currentPath.subdivisions, 1, 100));
            float   uvResolution = EditorGUILayout.Slider("Uv resolution", _currentPath.uvResolution, 0.2f, 10.0f);
            bool    loopCurve    = EditorGUILayout.Toggle("Loop curve", _currentPath.loopCurve);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_currentPath, "Modify Path Settings");
                EditorUtility.SetDirty(_currentPath);
                _currentPath.scale        = scale;
                _currentPath.subdivisions = subdivisions;
                _currentPath.uvResolution = uvResolution;
                _currentPath.loopCurve    = loopCurve;
            }

            GUILayout.Space(20);

            for (int i = 0; i < _currentPath.pathData.Length; i++)
            {
                if (PathPointEditor.selectedId == i)
                {
                    PathPointEditor.EditPointGUI(i);
                }
            }

            if (GUILayout.Button("Add Point"))
            {
                Undo.RecordObject(_currentPath, "Add point");
                EditorUtility.SetDirty(_currentPath);
                _currentPath.pathData.AddPoint(_currentPath.transform.position);
                SceneView.RepaintAll();
            }

            if (GUILayout.Button("Remove Point") && _currentPath.pathData.Length > 1)
            {
                Undo.RecordObject(_currentPath, "Remove point");
                EditorUtility.SetDirty(_currentPath);
                _currentPath.pathData.RemovePoint(PathPointEditor.selectedId);
                SceneView.RepaintAll();
            }

            GUILayout.Space(20);

            _autoGenerateRoad = EditorGUILayout.Toggle("Auto Generate", _autoGenerateRoad);

            if (!_autoGenerateRoad && GUILayout.Button("Generate Road"))
            {
                _currentPath.UpdatePath();
                SceneView.RepaintAll();
            }
        }
Exemplo n.º 3
0
        private void OnEnable()
        {
            _currentPath = (ShapeTracerPath)target;

            PathPointEditor.Init(_currentPath);
        }
Exemplo n.º 4
0
 private void OnDisable()
 {
     _currentPath = null;
     PathPointEditor.Disable();
 }