using System; using UnityEngine; using UniRx; using HighlightPlus; public class SourceController : MonoBehaviour { public CreationMode sourceMode; private DateTime t1, t2; public string OriginaName; private void Start() { Observable.EveryLateUpdate() .Subscribe(_ => { if (MainMenu.Instance.MenuMode == MainMenuMode.周边水源) { if (gameObject == WaterSource.Instance.Selected) GetComponent().highlighted = true; else GetComponent().highlighted = false; } if (MainMenu.Instance.MenuMode == MainMenuMode.行车路线) { switch (sourceMode) { case CreationMode.Single: if (gameObject == DriveRoute.Instance.Selected) GetComponent().highlighted = true; else GetComponent().highlighted = false; break; case CreationMode.Multipoint: if (transform.parent.gameObject == DriveRoute.Instance.Selected) { foreach (Transform t in transform.parent) t.gameObject.GetComponent().highlighted = true; } else GetComponent().highlighted = false; break; } } }).AddTo(gameObject); } void OnMouseDown() { if (MainMenu.Instance.MenuMode == MainMenuMode.周边水源) { WaterSource.Instance.Selected = gameObject; } if (MainMenu.Instance.MenuMode == MainMenuMode.行车路线) { switch (sourceMode) { case CreationMode.Single: DriveRoute.Instance.Selected = gameObject; break; case CreationMode.Multipoint: DriveRoute.Instance.Selected = transform.parent.gameObject; break; } } t2 = DateTime.Now; if (t2 - t1 < new TimeSpan(0, 0, 0, 0, 500)) { OnEditName(); } t1 = t2; } void OnEditName() { UIManager.Instance.Show(SetInfo); } private void SetInfo() { UIManager.Instance.GetView().NameInput.text= transform.Find("info").GetComponent().text; UIManager.Instance.GetView().SourceObject = gameObject; } }