Browse Source

Editor: GUI fix

Виктор Шейко 4 years ago
parent
commit
5b839500ae

+ 3 - 3
Assets/Scripts/Components/WallCreate.cs

@@ -13,7 +13,7 @@ public class WallCreate : MonoBehaviour
     public bool move = false;
     public bool BoxColliderEnabled = true;
     public enum Mode { Wall, Room, Pole, Cursor};
-    public static Mode mode = Mode.Wall;
+    public static Mode mode = Mode.Cursor;
     GameObject wall;
     public static List<GameObject> Walls = new List<GameObject>();
     public static List<Wall> Rooms = new List<Wall>();
@@ -126,7 +126,7 @@ public class WallCreate : MonoBehaviour
     private void OnMouseUp()
     {
         var end_pos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
-        Debug.Log($"end_pos = {end_pos}");
+        //Debug.Log($"end_pos = {end_pos}");
 
         if (mode == Mode.Room) Rooms.Add(new Wall { start_width = start_pos.x, start_height = start_pos.z, end_width = scale_x, end_height = scale_z });
 
@@ -152,5 +152,5 @@ public class WallCreate : MonoBehaviour
                 Walls.Add(room.transform.GetChild(i).gameObject);
             
         return room;
-    }
+    } 
 }

+ 2 - 0
Assets/Scripts/Controllers/BeaconController.cs

@@ -55,6 +55,7 @@ public class BeaconController : MonoBehaviour
             info = true;
             text.gameObject.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 100);
             text.gameObject.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 15);
+            transform.GetComponent<LabelObjectScript>().enabled = false;
         }        
     }
 
@@ -82,6 +83,7 @@ public class BeaconController : MonoBehaviour
             text.text = text_info;
             text.gameObject.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 120);
             text.gameObject.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 75);
+            transform.GetComponent<LabelObjectScript>().enabled = true;
         }
     }
 }

+ 10 - 7
Assets/Scripts/Controllers/CameraController.cs

@@ -27,14 +27,17 @@ public class CameraController : MonoBehaviour
 
     void Update()
     {
-        switch (axes)
+        if (!EventSystem.current.IsPointerOverGameObject())
         {
-            case RotationAxes.Mouse:
-                MouseCommands();
-                break;
-            case RotationAxes.TrackMarker:
-                TrackMarker();
-                break;
+            switch (axes)
+            {
+                case RotationAxes.Mouse:
+                    MouseCommands();
+                    break;
+                case RotationAxes.TrackMarker:
+                    TrackMarker();
+                    break;
+            }
         }
     }   
 

+ 0 - 2
Assets/Scripts/Controllers/EditorController.cs

@@ -180,6 +180,4 @@ public class EditorController : MonoBehaviour
 
         Beacons.Add(b);
     }
-
-
 }

+ 28 - 6
Assets/Scripts/Controllers/ModeController.cs

@@ -18,6 +18,7 @@ public class ModeController : MonoBehaviour
     public GameObject Markers;
     public GameObject Beacons;
     public GameObject Walls;
+    public GameObject WallCursor;
 
     Transform maps;
 
@@ -85,14 +86,32 @@ public class ModeController : MonoBehaviour
             Beacons.transform.GetChild(i).GetComponent<BeaconController>().mode = BeaconController.Mode.Player;
             Beacons.transform.GetChild(i).GetComponent<LabelObjectScript>().enabled = true;
         }
-        
-            //PlayerController.markers = new List<Marker>();
-            //client.SendGetUsers((uint)PlayerController.active_company + 1);
 
-            //PlayerController.Beacons = new List<Beacon>(); 
-            //client.BeaconsRequest((uint)PlayerController.locations[DropdownLocation.value].id);
+        WallCursor.SetActive(false);
+
+        GameObject old_button = null;
+        switch (WallCreate.mode)
+        {
+            case WallCreate.Mode.Cursor:
+                old_button =EditorTools.transform.GetChild(0).gameObject;
+                break;
+            case WallCreate.Mode.Room:
+                old_button = EditorTools.transform.GetChild(1).gameObject;
+                break;
+            case WallCreate.Mode.Wall:
+                old_button = EditorTools.transform.GetChild(2).gameObject;
+                break;
         }
 
+        if (old_button != null) old_button.GetComponent<Image>().color = Color.white;
+
+        //PlayerController.markers = new List<Marker>();
+        //client.SendGetUsers((uint)PlayerController.active_company + 1);
+
+        //PlayerController.Beacons = new List<Beacon>(); 
+        //client.BeaconsRequest((uint)PlayerController.locations[DropdownLocation.value].id);
+    }
+
     void EditorMode()
     {
         Player.SetActive(false);
@@ -117,7 +136,10 @@ public class ModeController : MonoBehaviour
             Beacons.transform.GetChild(i).GetComponent<BeaconController>().mode = BeaconController.Mode.Editor;     
             Beacons.transform.GetChild(i).GetComponent<LabelObjectScript>().enabled = false;                
         }
-        
+
+        var color = new Color();
+        ColorUtility.TryParseHtmlString("#C8C8C8", out color);
+        EditorTools.transform.GetChild(0).gameObject.GetComponent<Image>().color = color;
 
         //foreach (var m in PlayerController.markers)
         //{

+ 26 - 3
Assets/Scripts/Controllers/ToolsController.cs

@@ -11,7 +11,7 @@ public class ToolsController : MonoBehaviour
     public int Rounding = 1;
     
     enum Tools { Wall, Room, Del, Cursor};
-    Tools tools = Tools.Cursor;
+   // Tools tools = Tools.Cursor;
 
 
     // Start is called before the first frame update
@@ -29,13 +29,14 @@ public class ToolsController : MonoBehaviour
     public void CursorOff()
     {
         Cursor.SetActive(false);
-        tools = Tools.Cursor;
+        SelectButton(transform.GetChild(0).gameObject);
         WallCreate.mode = WallCreate.Mode.Cursor;
     }
 
     public void WallEdit()
     {
         Cursor.SetActive(true);
+        SelectButton(transform.GetChild(2).gameObject);
         WallCreate.mode = WallCreate.Mode.Wall;
     }
 
@@ -43,12 +44,34 @@ public class ToolsController : MonoBehaviour
     public void RoomEdit()
     {
         Cursor.SetActive(true);
+        SelectButton(transform.GetChild(1).gameObject);
         WallCreate.mode = WallCreate.Mode.Room;
     }
 
     public void Delete()
     {
-        tools = Tools.Del;
+        //tools = Tools.Del;
     }
 
+    public void SelectButton(GameObject button)
+    {
+        var color = new Color();
+        ColorUtility.TryParseHtmlString("#C8C8C8", out color);
+        GameObject old_button = null;
+        switch (WallCreate.mode)
+        {
+            case WallCreate.Mode.Cursor:
+                old_button = transform.GetChild(0).gameObject;
+                break;
+            case WallCreate.Mode.Room:
+                old_button = transform.GetChild(1).gameObject;
+                break;
+            case WallCreate.Mode.Wall:
+                old_button = transform.GetChild(2).gameObject;
+                break;
+        }
+
+        if (old_button != null) old_button.GetComponent<Image>().color = Color.white;
+        button.GetComponent<Image>().color = color;
+    }
 }