public void RebuildWindow(ViewPageItem viewPageItem) { this.viewPageItem = viewPageItem; reorderableList = null; reorderableList = new ReorderableList(viewPageItem.breakPointViewElementTransforms, typeof(List <BreakPointViewElementTransform>), true, true, true, true); reorderableList.drawElementCallback += DrawViewItemElement; reorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 6f; reorderableList.onAddCallback += AddItem; reorderableList.elementHeightCallback += ElementHight; }
public void SetViewPageItem(ViewPageItem viewPageItem) { this.viewPageItem = viewPageItem; currentSelectGameObject = null; if (viewPageItem == null) { return; } target = viewPageItem.viewElement.gameObject; CacheHierarchy(); RebuildModifyReorderableList(); if (ViewSystemVisualEditor.RequireAutoRefreshMethodDatabase()) { ViewSystemVisualEditor.RefreshMethodDatabase(); } }
void DrawItem(ViewPageItem vpi, bool isViewState = false) { using (var vertical2 = new GUILayout.VerticalScope(Drawer.darkBoxStyle)) { using (var horizon = new GUILayout.HorizontalScope()) { GUILayout.Label(new GUIContent($"{vpi.displayName}", Drawer.prefabIcon), EditorStyles.whiteLabel, GUILayout.Height(16)); GUILayout.FlexibleSpace(); GUILayout.Label($"({vpi.Id})"); } if (vpi.viewElement == null) { GUILayout.Label(new GUIContent("ViewElement is not set up!", Drawer.miniErrorIcon)); return; } var selectables = vpi.viewElement.GetComponentsInChildren <Selectable>(); foreach (var select in selectables) { using (var vertical3 = new GUILayout.VerticalScope("box")) { var path = AnimationUtility.CalculateTransformPath(select.transform, vpi.viewElement.transform); var component = select.GetType().ToString(); using (var horizon = new GUILayout.HorizontalScope()) { using (var vertical4 = new GUILayout.VerticalScope()) { var p = path.Split('/'); GUILayout.Label(new GUIContent($"{vpi.viewElement.name}", Drawer.prefabIcon), GUILayout.Height(16)); for (int i = 0; i < p.Length; i++) { if (string.IsNullOrEmpty(p[i])) { continue; } using (var horizon2 = new GUILayout.HorizontalScope()) { GUILayout.Space((i + 1) * 15); GUILayout.Label(new GUIContent($"{p[i]}", Drawer.prefabIcon), GUILayout.Height(16)); } } } GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(Drawer.arrowIcon)); var editorContent = new GUIContent(EditorGUIUtility.ObjectContent(select, select.GetType())); GUILayout.FlexibleSpace(); GUILayout.Label(editorContent, height); } ViewElementNavigationData currentNavSetting = null; ViewElementNavigationDataViewState viewElementNavigationDataViewState = null; if (isViewState == false) { currentNavSetting = vpi.navigationDatas .SingleOrDefault(m => m.targetComponentType == component && m.targetTransformPath == path ); } else { viewElementNavigationDataViewState = viewPage.navigationDatasForViewState.SingleOrDefault(m => m.viewPageItemId == vpi.Id); if (viewElementNavigationDataViewState != null) { currentNavSetting = viewElementNavigationDataViewState.navigationDatas .SingleOrDefault(m => m.targetComponentType == component && m.targetTransformPath == path ); } } bool hasSetting = currentNavSetting != null; using (var horizon = new GUILayout.HorizontalScope()) { if (GUILayout.Button("Select In Hierarchy", EditorStyles.miniButton)) { if (vpi.previewViewElement) { Selection.objects = new UnityEngine.Object[] { vpi.previewViewElement.transform.Find(path).gameObject }; } } using (var disable = new EditorGUI.DisabledGroupScope(!hasSetting)) { if (GUILayout.Button("Apply Setting", EditorStyles.miniButton)) { ApplySetting(); } } } if (!hasSetting) { if (GUILayout.Button("Add Navigation Setting")) { if (isViewState == false) { var nav = new ViewElementNavigationData(); nav.targetComponentType = component; nav.targetTransformPath = path; nav.mode = select.navigation.mode; vpi.navigationDatas.Add(nav); } else { if (viewElementNavigationDataViewState == null) { viewElementNavigationDataViewState = new ViewElementNavigationDataViewState(); viewElementNavigationDataViewState.viewPageItemId = vpi.Id; } var nav = new ViewElementNavigationData(); nav.targetComponentType = component; nav.targetTransformPath = path; nav.mode = select.navigation.mode; viewElementNavigationDataViewState.navigationDatas.Add(nav); viewPage.navigationDatasForViewState.Add(viewElementNavigationDataViewState); } } } else { using (var horizon = new GUILayout.HorizontalScope()) { using (var check = new EditorGUI.ChangeCheckScope()) { var result = (UnityEngine.UI.Navigation.Mode) EditorGUILayout.EnumPopup(currentNavSetting.mode); if (result != UnityEngine.UI.Navigation.Mode.Explicit) { currentNavSetting.mode = result; } else { ViewSystemLog.LogError("Currently Navigation Setting doesn't support Mode with Explicit"); } if (check.changed) { //Do something if (autoApplyNavigation) { ApplySetting(); } } } if (GUILayout.Button(new GUIContent(EditorGUIUtility.FindTexture("d_TreeEditor.Trash")), Drawer.removeButtonStyle, GUILayout.Width(25))) { if (isViewState == false) { vpi.navigationDatas.Remove(currentNavSetting); } else { viewElementNavigationDataViewState.navigationDatas.Remove(currentNavSetting); } } } } void ApplySetting() { if (isViewState == false) { vpi.previewViewElement.ApplyNavigation(vpi.navigationDatas); } else { vpi.previewViewElement.ApplyNavigation(viewElementNavigationDataViewState.navigationDatas); } SceneView.RepaintAll(); } } } } }