private void Start() { UlEventSystem.GetSubject <DataEventType, ChangeModuleEventData>(DataEventType.ChangeModule) .Subscribe(eventData => { if (eventData == null) { return; } string module = eventData.Module; if (string.IsNullOrWhiteSpace(module)) { module = null; } if (GlobalData.CurrentModule == module) { return; } List <string> removeElements = GlobalData.CurrentSelectDisplayObjectDic.KeyList(); if (removeElements != null) { HistoryManager.Do(BehaviorFactory.GetUpdateSelectDisplayObjectBehavior(GlobalData.CurrentModule, null, removeElements, CombineType.Previous)); } GlobalData.CurrentModule = module; DisplayObjectUtil.RemoveAllDisplayObjectBehavior(); DisplayObjectUtil.AddAllDisplayObjectBehavior(); UlEventSystem.DispatchTrigger <DataEventType>(DataEventType.CurrentModuleNameChanged); GetComponent <RectTransform>().localPosition = Vector2.zero; scaleSlider.value = 10f; }); UlEventSystem.GetTriggerSubject <DataEventType>(DataEventType.CurrentModuleNameChanged) .Subscribe(_ => { UlEventSystem.DispatchTrigger <UIEventType>(UIEventType.UpdateModuleTxtWidth); moduleNameText.text = string.IsNullOrWhiteSpace(GlobalData.CurrentModule) ? "null" : GlobalData.CurrentModule; }); UlEventSystem.GetSubject <UIEventType, TriggerEventData>(UIEventType.UpdateModuleTxtWidth) .SampleFrame(1) .DelayFrame(0) .Subscribe(_ => { RectTransform rt = moduleNameText.GetComponent <RectTransform>(); RectTransform rt2 = selectedDisplayObjectText.GetComponent <RectTransform>(); rt2.anchoredPosition = new Vector2(rt.anchoredPosition.x + rt.sizeDelta.x + 30, rt2.anchoredPosition.y); }); UlEventSystem.GetSubject <DataEventType, SelectedChangeData>(DataEventType.SelectedChange) .Subscribe(eventData => { if (eventData == null || string.IsNullOrWhiteSpace(eventData.ModuleName) || !eventData.ModuleName.Equals(GlobalData.CurrentModule)) { return; } if (eventData.RemoveElements != null) { foreach (Transform displayObject in eventData.RemoveElements .Select(elementName => { GlobalData.CurrentDisplayObjectDic.TryGetValue(elementName, out Transform displayObject); return(displayObject); }) .Where(displayObject => displayObject)) { displayObject.GetComponent <FrameManager>().IsSelect = false; } } if (eventData.AddElements != null) { foreach (Transform displayObject in eventData.AddElements .Select(elementName => GlobalData.CurrentDisplayObjectDic[elementName]) .Where(displayObject => displayObject)) { displayObject.GetComponent <FrameManager>().IsSelect = true; } } if (GlobalData.CurrentSelectDisplayObjectDic.Count < 1) { selectedDisplayObjectText.text = "null"; return; } StringBuilder sb = new StringBuilder(); foreach (var pair in GlobalData.CurrentSelectDisplayObjectDic) { sb.Append($"{pair.Value.name}, "); pair.Value.GetComponent <FrameManager>().IsSelect = true; } selectedDisplayObjectText.text = sb.ToString(0, sb.Length - 2); }); GlobalData.GlobalObservable.ObserveEveryValueChanged(_ => GlobalData.ModifyDic) .SampleFrame(1) .Subscribe(modifyCount => UlEventSystem.DispatchTrigger <UIEventType>(UIEventType.UpdateTitle)); GlobalData.GlobalObservable.ObserveEveryValueChanged(_ => GlobalData.CurrentFilePath) .SampleFrame(1) .Subscribe(_ => UlEventSystem.DispatchTrigger <UIEventType>(UIEventType.UpdateTitle)); UlEventSystem.GetSubject <UIEventType, TriggerEventData>(UIEventType.UpdateTitle) .SampleFrame(1) .Subscribe(_ => { string title = GlobalData.ProductName; if (!string.IsNullOrWhiteSpace(GlobalData.CurrentFilePath)) { title = GlobalData.CurrentFilePath; } Utils.ChangeTitle(GlobalData.ModifyCount != 0 ? $"* {title}" : title); }); }