コード例 #1
0
 public static void Update(SceneView view)
 {
     if (instance != null)
     {
         if (!EditorApplication.isPlaying && Event.current.capsLock && WaypointDebug.isCreatingPoints())
         {
             if (Event.current.shift)
             {
                 Debug.Log("STUFS!!!s");
             }
             Ray        ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
             RaycastHit hit;
             if (Physics.Raycast(ray, out hit, WaypointSettings.getRange()))
             {
                 float roundedX = Mathf.Round(hit.point.x * 1000) / 1000;
                 float roundedY = Mathf.Round(hit.point.y * 1000) / 1000;
                 float roundedZ = Mathf.Round(hit.point.z * 1000) / 1000;
                 WaypointDebug.setCurrentLocation(new Vector3(roundedX, roundedY, roundedZ));
                 GetWindow(typeof(WaypointCreator)).Repaint();
             }
             else
             {
                 if (WaypointDebug.getCurrentLocation() != Vector3.zero)
                 {
                     WaypointDebug.setCurrentLocation(Vector3.zero);
                     GetWindow(typeof(WaypointCreator)).Repaint();
                 }
             }
         }
     }
 }
コード例 #2
0
    void OnGUI()
    {
        if (instance == null)
        {
            instance = this;
        }
        WaypointDebug.setCreatingPoints(EditorGUILayout.Toggle("Creating Point", WaypointDebug.isCreatingPoints()));

        EditorGUILayout.Space();
        WaypointDebug.setCurrentLocation(EditorGUILayout.Vector3Field("", WaypointDebug.getCurrentLocation()));

        if (GUILayout.Button("Make new Point"))
        {
            if (WaypointDebug.isCreatingPoints())
            {
                saveNewWaypoint();
            }
        }

        //Connect/Disconnect points
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Connect/Disconnect Points");
        points = EditorGUILayout.Vector2IntField("", points);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Connect"))
        {
            if (points.x != points.y)
            {
                connectPoints();
            }
        }

        if (GUILayout.Button("Disconnect"))
        {
            if (points.x != points.y)
            {
                disconnectPoints();
            }
        }
        GUILayout.EndHorizontal();

        //Delete point..
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Delete Point");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Delete"))
        {
            //TODO: Delete point...
        }
        toDelete = EditorGUILayout.IntField("", toDelete);
        EditorGUILayout.EndHorizontal();
    }