//绘制cluster view功能面板 protected void DrawClusterViewField() { string clusterViewName = "Not Registered"; if (m_clusterView != null && m_clusterView.objectReferenceValue != null) { clusterViewName = m_clusterView.objectReferenceValue.name + "(" + m_clusterView.objectReferenceValue.GetType().FullName + ")"; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Cluster View", clusterViewName); if (!Application.isPlaying && GUILayout.Button("Register")) { if (m_clusterView.objectReferenceValue == null) { FduClusterView view = ((FduObserverBase)target).findViewInstance(); if (view != null) { m_clusterView.objectReferenceValue = view; view.registToView(((FduObserverBase)target)); serializedObject.ApplyModifiedProperties(); } } } if (!Application.isPlaying && GUILayout.Button("Reset")) { if (m_clusterView.objectReferenceValue != null) { ((FduObserverBase)target).removeFromClusterView_editor(); m_clusterView.objectReferenceValue = null; serializedObject.ApplyModifiedProperties(); } } EditorGUILayout.EndHorizontal(); }
//绘制子窗口 public override void DrawSubWindow() { var leftOffset = new GUIStyle(); leftOffset.margin.left = 10; if (!Application.isPlaying) { GUI.Label(subWindowRect, new GUIContent("You can get the information of cluster views at run time", parentWindow.hintTexture), FduEditorGUI.getTitleStyle_LevelOne()); return; } //画两个Box 上面用于列表 下面用于详细内容 GUI.Box(viewScroll, ""); GUI.Box(detailScroll, ""); views = FduClusterViewManager.getClusterViews(); FduClusterView view = null; //==========================================搜索与总数部分Start=================================== EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(leftOffset, GUILayout.Width(subWindowRect.width)); EditorGUILayout.LabelField("Total views ", FduClusterViewManager.getViewCount().ToString(), leftOffset); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(leftOffset, GUILayout.Width(subWindowRect.width)); searchText_view = EditorGUILayout.TextField("Search", searchText_view, GUILayout.Width(subWindowRect.width * 0.5f), GUILayout.Height(20)); EditorGUILayout.Space(); if (GUILayout.Button("Clear", GUILayout.Height(21))) { Debug.Log("click clear"); searchText_view = ""; searchingFlag = false; EditorGUI.FocusTextInControl(""); } if (GUILayout.Button("Search", GUILayout.Height(21))) { searchingFlag = true; EditorGUI.FocusTextInControl(""); } EditorGUILayout.EndHorizontal(); //==========================================搜索与总数部分End=================================== //==========================================View列表部分Start=================================== leftOffset.margin.left += 15; //var center = new GUIStyle(); //center.alignment = TextAnchor.MiddleCenter; var labelStyle = new GUIStyle(); labelStyle.fontStyle = FontStyle.Bold; EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(leftOffset, GUILayout.Width(subWindowRect.width)); EditorGUILayout.LabelField("ViewId", labelStyle, GUILayout.Width(viewScroll.width * 0.07f)); EditorGUILayout.LabelField("Name", labelStyle, GUILayout.Width(viewScroll.width * 0.25f)); EditorGUILayout.LabelField("Path", labelStyle, GUILayout.Width(viewScroll.width * 0.5f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); var Nonestyle = new GUIStyle(); Nonestyle.name = "a"; viewScrollPos = EditorGUILayout.BeginScrollView(viewScrollPos, leftOffset, GUILayout.Width(viewScroll.width - 10), GUILayout.Height(viewScroll.height - 10)); string id, name, path; float len1, len2, len3, len4; len1 = viewScroll.width * 0.07f; len2 = viewScroll.width * 0.25f; len3 = viewScroll.width * 0.5f; len4 = viewScroll.width * 0.1f; int listCount = 0; while (views.MoveNext()) { view = views.Current.Value; if (view == null) { //EditorGUILayout.HelpBox("One view is disappeared but reference still exist in cluster manager!", MessageType.Warning); } else { id = view.ViewId.ToString(); name = view.name; path = FduSupportClass.getGameObjectPath(view.gameObject); if (!searchingFlag || checkSearchText(id, name, path)) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(id, GUILayout.Width(len1)); EditorGUILayout.LabelField(name, GUILayout.Width(len2)); EditorGUILayout.LabelField(path, GUILayout.Width(len3)); if (GUILayout.Button("Detail", GUILayout.Width(len4))) { selectedViewId = views.Current.Value.ViewId; } EditorGUILayout.EndHorizontal(); listCount++; } } } bool noViewFlag = false; if (listCount == 0) { noViewFlag = true; } //为了强制显示scroll view 的进度条 BeginScrollView里面的alwaysShowVertical参数没用 for (int i = listCount; i < 22; ++i) { EditorGUILayout.LabelField(""); } EditorGUILayout.EndScrollView(); if (noViewFlag) { GUI.Label(viewScroll, new GUIContent("No Registed View", parentWindow.hintTexture), FduEditorGUI.getTitleStyle_LevelOne()); } //for (int i = 0; i < 500; ++i) //{ // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField(i.ToString(), GUILayout.Width(len1)); // EditorGUILayout.LabelField("tentententententenssssssssssssssssssssss", GUILayout.Width(len2)); // EditorGUILayout.LabelField("miao/ssss/wwww/qqqq/aaaa/zzzz/xxxx/ccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", GUILayout.Width(len3)); // GUILayout.Button("Yes" + i, GUILayout.Width(len4)); // EditorGUILayout.EndHorizontal(); //} //==========================================View列表部分End=================================== var selectedView = FduClusterViewManager.getClusterView(selectedViewId); if (selectedView == null) { GUI.Label(detailScroll, new GUIContent("No Selected View", parentWindow.hintTexture), FduEditorGUI.getTitleStyle_LevelOne()); selectedViewId = -1; return; } //==========================================View detail 部分=================================== leftOffset.margin.top = 25; detailScrollPos = EditorGUILayout.BeginScrollView(detailScrollPos, leftOffset, GUILayout.Width(detailScroll.width - 10), GUILayout.Height(detailScroll.height - 10)); var pstyle = new GUIStyle(); pstyle.wordWrap = true; pstyle.margin.left = 5; EditorGUILayout.LabelField("ViewId: " + selectedView.ViewId + " GameObject Name: " + selectedView.name + " Observer Count: " + selectedView.getObserverCount(), GUILayout.Width(detailScroll.width - 50.0f)); EditorGUILayout.LabelField("Path: " + FduSupportClass.getGameObjectPath(selectedView.gameObject), pstyle, GUILayout.Width(detailScroll.width - 50.0f)); if (selectedView.getObserverCount() <= 0) { EditorGUILayout.EndScrollView(); return; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("GameObject Name", GUILayout.Width(detailScroll.width * 0.3f)); EditorGUILayout.LabelField("Observer Type", GUILayout.Width(detailScroll.width * 0.3f)); EditorGUILayout.LabelField("DTS Type", GUILayout.Width(detailScroll.width * 0.2f)); EditorGUILayout.LabelField("DTS Parameter", GUILayout.Width(detailScroll.width * 0.3f)); EditorGUILayout.EndHorizontal(); List <FduObserverBase> .Enumerator observers = selectedView.getObservers(); string dtsName = "NULL"; string dtsPara = "NULL"; while (observers.MoveNext()) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(observers.Current.name, GUILayout.Width(detailScroll.width * 0.3f)); EditorGUILayout.LabelField(observers.Current.GetType().FullName, GUILayout.Width(detailScroll.width * 0.3f)); if (observers.Current.getDataTransmitStrategy() != null) { dtsName = observers.Current.getDataTransmitStrategy().GetType().FullName; dtsPara = getDTSParaInfo(observers.Current.getDataTransmitStrategy()); //dtsPara = observers.Current.getDataTransmitStrategy().getCustomData().ToString(); } EditorGUILayout.LabelField(dtsName, GUILayout.Width(detailScroll.width * 0.2f)); EditorGUILayout.LabelField(dtsPara, GUILayout.Width(detailScroll.width * 0.3f)); EditorGUILayout.EndHorizontal(); } //for (int i = 0; i < 10; ++i) //{ // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField("Observer GameObject name",GUILayout.Width(detailScroll.width*0.3f)); // EditorGUILayout.LabelField("FduTransformObserver", GUILayout.Width(detailScroll.width * 0.3f)); // EditorGUILayout.LabelField("FduDTS_Direct", GUILayout.Width(detailScroll.width * 0.2f)); // EditorGUILayout.LabelField("OnGetPlayerSetIKEvent", GUILayout.Width(detailScroll.width * 0.3f)); // EditorGUILayout.EndHorizontal(); //} EditorGUILayout.EndScrollView(); //==========================================View detail 部分=================================== }
public override void OnInspectorGUI() { serializedObject.Update(); m_target = (FduClusterView)target; if (Application.isPlaying) { EditorGUILayout.LabelField("ViewID", m_target.ViewId.ToString()); } else { EditorGUILayout.LabelField("ViewID", "Set at run time"); } if (EditorUtility.IsPersistent(m_target.gameObject) && m_target.gameObject.transform.parent == null) { EditorGUILayout.LabelField("SubviewCount", m_subViewList.arraySize.ToString()); for (int i = 0; i < m_subViewList.arraySize; ++i) { EditorGUILayout.LabelField("sub view name", m_subViewList.GetArrayElementAtIndex(i).objectReferenceValue.name); } EditorGUILayout.BeginHorizontal(); m_target.IsObservingCreation = EditorGUILayout.Toggle("Observe Creation", m_target.IsObservingCreation); if (m_target.IsObservingCreation) { EditorGUILayout.LabelField("Asset Id", m_assetId.intValue.ToString()); if (m_assetId.intValue < 0) { EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("This Prefab is not added to AssetManager. Please find FduClutserAssetManager and press refresh.", MessageType.Error); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); m_target.IsObservingDestruction = EditorGUILayout.Toggle("Observe Destruction", m_target.IsObservingDestruction); m_target.IsObservingActiveState = EditorGUILayout.Toggle("Observe Active State*", m_target.IsObservingActiveState); EditorGUILayout.EndHorizontal(); var bold = new GUIStyle(); bold.fontStyle = FontStyle.Bold; _advaceSettingFold = EditorGUILayout.Foldout(_advaceSettingFold, "Advance Setting"); if (_advaceSettingFold) { EditorGUILayout.BeginHorizontal(); m_target.IsImmediatelyDeserialize = EditorGUILayout.Toggle("Is ImmediatelyDeserialize", m_target.IsImmediatelyDeserialize); m_target.IsAutomaticllySend = EditorGUILayout.Toggle("Is Automaticlly Send", m_target.IsAutomaticllySend); EditorGUILayout.EndHorizontal(); m_target.resendPriority = (FDUObjectSync.Message.ResendPriority)EditorGUILayout.EnumPopup("Data Resend Priority", m_target.resendPriority); } if (m_parentView.objectReferenceValue != null) { EditorGUILayout.LabelField("ParentView", m_parentView.objectReferenceValue.name); } if (m_target.IsObservingActiveState) { EditorGUILayout.HelpBox("When you are using observing active state,please review considerations in the document.", MessageType.Info); } GUIStyle style = new GUIStyle(); style.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField(new GUIContent("Observer List", FduEditorGUI.getObserverIcon()), style); if (Application.isPlaying) //程序运行时不允许额外操作 { List <FduObserverBase> .Enumerator enumerator = m_target.getObservers(); int i = 0; while (enumerator.MoveNext()) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(i + " " + enumerator.Current.gameObject.name + "(" + enumerator.Current.GetType().Name + ")"); EditorGUILayout.EndHorizontal(); i++; } } else { SerializedProperty property; bool hintFlag = false; for (int i = 0; i < m_observerList.arraySize; ++i) { property = m_observerList.GetArrayElementAtIndex(i); if (property.objectReferenceValue == null || !m_target.Equals(((FduObserverBase)(property.objectReferenceValue)).GetClusterView())) //如果obsever列表中的值为空 或者对应observer所属的view不是本view 则需要重新刷新 { hintFlag = true; } else { EditorGUILayout.LabelField(((FduObserverBase)property.objectReferenceValue).gameObject.name + "(" + ((FduObserverBase)property.objectReferenceValue).GetType().FullName + ")"); } } for (int i = 0; i < m_subViewList.arraySize; ++i) { property = m_subViewList.GetArrayElementAtIndex(i); if (property.objectReferenceValue == null) { hintFlag = true; } } if (hintFlag) { Refresh(); } if (GUILayout.Button("Refresh")) { Refresh(); } } if (GUI.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); } }