Beispiel #1
0
 private void OnSceneGUI()
 {
     RoadMesh.DrawHandles(road.Nodes);
     if (targetTransform.hasChanged && road.Nodes.Count >= 2)
     {
         var meshes = RoadMesh.GenerateRoadMesh(road.Nodes);
         road.SetMesh(meshes);
         targetTransform.hasChanged = false;
     }
 }
Beispiel #2
0
        private void OnSceneGUI()
        {
            EditorGUI.BeginChangeCheck();
            var nodes = road.Nodes;

            RoadMesh.DrawHandles(nodes);

            EditorGUI.BeginChangeCheck();
            if (Tools.current == Tool.Move)
            {
                foreach (var node in nodes)
                {
                    Vector3 position = Handles.PositionHandle(node.transform.position, node.transform.rotation);
                    node.transform.position = position;
                }
            }
            if (Tools.current == Tool.Rotate)
            {
                foreach (var node in nodes)
                {
                    Quaternion rotation = Handles.RotationHandle(node.transform.rotation, node.transform.position);
                    node.transform.rotation = rotation;
                }
            }
            if (Tools.current == Tool.Scale)
            {
                foreach (var node in nodes)
                {
                    float   size  = HandleUtility.GetHandleSize(node.transform.position);
                    Vector3 scale = Handles.ScaleHandle(node.transform.localScale, node.transform.position, node.transform.rotation, size);
                    node.transform.localScale = scale;
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                road.SetMesh(RoadMesh.GenerateRoadMesh(road.Nodes));
                EditorUtility.SetDirty(road);
            }
        }