コード例 #1
0
        //----- property -----

        //----- method -----

        public static RecordWindow Open(MasterController masterController)
        {
            RecordWindow recordWindow = null;

            // 開いているウィンドウ取得.
            var window = FindWindow(masterController.MasterType);

            // 1つのマスターにつき1ウィンドウまでしか開かない.
            if (window == null)
            {
                window = CreateInstance <RecordWindow>();

                window.Initialize(masterController);

                EditorApplication.delayCall += () =>
                {
                    window.Show();
                };

                recordWindow = window;
            }

            window.Focus();

            return(recordWindow);
        }
コード例 #2
0
        void OnGUI()
        {
            Initialize();

            // マスターロード実行.

            if (loadMasterRequest)
            {
                LoadAllMasterData().Subscribe().AddTo(Disposable);
            }

            // Toolbar.

            using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.Height(15f)))
            {
                Action <string> onChangeSearchText = x =>
                {
                    searchText      = x;
                    displayContents = GetDisplayMasters();
                };

                Action onSearchCancel = () =>
                {
                    searchText      = string.Empty;
                    displayContents = GetDisplayMasters();
                };

                EditorLayoutTools.DrawToolbarSearchTextField(searchText, onChangeSearchText, onSearchCancel, GUILayout.MinWidth(150f));

                GUILayout.FlexibleSpace();

                if (EnableLoadButton)
                {
                    if (GUILayout.Button("Load", EditorStyles.toolbarButton, GUILayout.Width(40f)))
                    {
                        LoadAllMasterData().Subscribe().AddTo(Disposable);
                    }
                }

                if (GUILayout.Button("Close All", EditorStyles.toolbarButton, GUILayout.Width(60f)))
                {
                    CloseAllRecordWindow();
                }
            }

            // ScrollView.

            if (displayContents != null)
            {
                GUILayout.Space(2f);

                using (new ContentsScope())
                {
                    using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosition))
                    {
                        for (var i = 0; i < displayContents.Length; i++)
                        {
                            var content = displayContents[i];

                            var masterName = content.GetDisplayMasterName();

                            var color = content.HasChangedRecord ? EditedColor : Color.white;

                            using (new BackgroundColorScope(color))
                            {
                                if (GUILayout.Button(masterName))
                                {
                                    var recordViewerWindow = RecordWindow.Open(content);

                                    if (recordViewerWindow != null)
                                    {
                                        recordViewerWindow.OnChangeRecordAsObservable()
                                        .Subscribe(_ => Repaint())
                                        .AddTo(Disposable);
                                    }
                                }
                            }

                            if (i < displayContents.Length - 1)
                            {
                                GUILayout.Space(3f);
                            }
                        }

                        scrollPosition = scrollViewScope.scrollPosition;
                    }
                }

                GUILayout.Space(5f);
            }
        }