Selaa lähdekoodia

fix select all users

Виктор Шейко 4 vuotta sitten
vanhempi
commit
520889b4f9

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 506 - 275
Assets/Scenes/Player.unity


+ 47 - 0
Assets/Scripts/Components/SelectUsers.cs

@@ -0,0 +1,47 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class SelectUsers : MonoBehaviour
+{
+    GameObject UsersView;
+    Button buttonSelectAll;
+    Button buttonNoSelectAll;
+
+    // Start is called before the first frame update
+    void Start()
+    {
+        UsersView = GameObject.Find("UsersView");
+        buttonSelectAll = transform.GetChild(0).GetComponent<Button>();
+        buttonNoSelectAll = transform.GetChild(1).GetComponent<Button>();
+
+
+        buttonSelectAll.onClick.AddListener(() => { All(true); });
+        buttonNoSelectAll.onClick.AddListener(() => { All(false); });
+    }
+
+ private void All(bool select)
+    {
+        var player = PlayerController.instance;
+
+        switch (player.DropdownMode.value)
+        {
+            case 0:
+                foreach (var u in player.users.Values.Where(s => s.online == true))
+                    u.toggle.isOn = select;
+                break;
+            case 1:
+                foreach (var u in player.users.Values)
+                    u.toggle.isOn = select;
+                break;
+        }
+    }
+
+    public void SetActive(bool value)
+    {
+        UsersView.SetActive(value);
+        gameObject.SetActive(value);
+    }
+}

+ 11 - 0
Assets/Scripts/Components/SelectUsers.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f53dea7317b0ad343834a0dd6a17ab09
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
Assets/Scripts/Controllers/CompanyController.cs

@@ -26,7 +26,7 @@ public class CompanyController : MonoBehaviour
     public List<uint> locations_index; // сопоставление id с dropdown
                                        //public List<Marker> markers;
     public LocationZones LocationZones;
-    public GameObject UsersView;
+    public SelectUsers selectUsers;
     public WallCreate Cursor;
 
     PlayerController player;

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

@@ -56,7 +56,6 @@ public class EditorController : MonoBehaviour
 
         ButtonAddBeacon.onClick.AddListener(() => {
             AddBeacon(company);
-
         });
 
         var random = new System.Random();

+ 2 - 2
Assets/Scripts/Controllers/ModeController.cs

@@ -75,7 +75,7 @@ public class ModeController : MonoBehaviour
         foreach (var b in l.beacons.Values)
             b.beacon.GetComponent<BeaconController>().mode = BeaconController.Mode.Player;
         company.LocationZones.gameObject.SetActive(true);
-        company.UsersView.SetActive(true);
+        company.selectUsers.SetActive(true);
         l.plane.GetComponent<TouchScript>().Resize = false;
 
         var edit = Editor.GetComponent<EditorController>();
@@ -153,7 +153,7 @@ public class ModeController : MonoBehaviour
                 b.beacon.GetComponent<BeaconController>().mode = BeaconController.Mode.Editor;
         }
         company.LocationZones.gameObject.SetActive(false);
-        company.UsersView.SetActive(false);
+        company.selectUsers.SetActive(false);
         //l.plane.GetComponent<TouchScript>().Resize = false;
 
         //item = new Dropdown.OptionData("Новая локация");

+ 6 - 10
Assets/Scripts/Controllers/PlayerController.cs

@@ -27,7 +27,6 @@ public class PlayerController : MonoBehaviour
     public GameObject StartStopButton;
     public LocationZones locationZones;
     public Dropdown DropdownMode;
-    public Toggle ToggleAllUsers; // отображение всех маркеров пользователей
     public Toggle ToggleLine;
     public Toggle ToggleDisappearance;
 
@@ -82,12 +81,6 @@ public class PlayerController : MonoBehaviour
 
         var broadcast_stop = UserInfo.transform.GetChild(1).GetChild(1).GetComponent<Button>();
         broadcast_stop.onClick.AddListener(() => BroadcastStop());
-
-        ToggleAllUsers = GameObject.Find("ToggleAllUsers").GetComponent<Toggle>();
-        ToggleAllUsers.onValueChanged.AddListener(delegate {
-            foreach (var u in users.Values)
-                u.toggle.isOn = ToggleAllUsers.isOn;
-        });
     }
 
     // Update is called once per frame
@@ -351,9 +344,12 @@ public class PlayerController : MonoBehaviour
         {            
             case 0:
                 DateTimePanel.SetActive(false);
-                if(users != null)
-                foreach(var u in users)
-                    u.Value.toggle_user.SetActive(u.Value.online);
+                if (users != null)
+                    foreach (var u in users)
+                    {
+                        if(!u.Value.online) u.Value.toggle.isOn = false;
+                        u.Value.toggle_user.SetActive(u.Value.online);
+                    }
                 break;
             case 1:
                 DateTimePanel.SetActive(true);