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(); } }
public void VerifyEvents() { ViewSystemVisualEditor.RefreshMethodDatabase(); RefreshEventDatas(); eventDataNeedToFix.Clear(); foreach (var vpi in allEventDatas) { foreach (var item in vpi.eventDatas) { var t = MacacaGames.Utility.GetType(item.scriptName); if (t == null) { ViewSystemLog.LogError(item.targetComponentType + " still not fixed cannot be found, will ignore while verify property"); eventDataNeedToFix.Add(item); continue; } if (t.GetMethod(item.methodName, bindingFlags) == null) { ViewSystemLog.LogError($"{item.methodName} in {item.scriptName} cannot be found"); eventDataNeedToFix.Add(item); continue; } } } if (eventDataNeedToFix.Count > 0) { if (EditorUtility.DisplayDialog( "Something goes wrong!", "There are some event data is missing, do you want to open fixer window", "Yes, Please", "Not now")) { var window = ScriptableObject.CreateInstance <EventFixerWindow>(); window.SetData(eventDataNeedToFix, ViewSystemVisualEditor.classMethodInfo, () => { //Make sure SetDirty EditorUtility.SetDirty(saveData); }); window.ShowUtility(); } } else { ViewSystemLog.Log("Great, all events looks good!"); } }
void DrawEvent() { // EditorGUILayout.HelpBox(" also the target MonoBahaviour required to assign in GlobalSetting", MessageType.Info); // if (GUILayout.Button("Setting")) // { // ViewSystemVisualEditor.globalSettingWindow.show = true; // } using (var horizon = new GUILayout.HorizontalScope(GUILayout.Height(40))) { EditorGUILayout.HelpBox("Only the method which has \"Component\" parameters will be shown. If you don't see your method in dropdown list, you can try 'Refresh'. (Very slow)", MessageType.Info); if (GUILayout.Button(new GUIContent(EditorGUIUtility.FindTexture("d_Refresh@2x"), "Refresh"), Drawer.removeButtonStyle, GUILayout.Width(40))) { ViewSystemVisualEditor.RefreshMethodDatabase(); } } if (ViewSystemVisualEditor.classMethodInfo.Count == 0) { return; } using (var scrollViewScope = new GUILayout.ScrollViewScope(scrollPositionEvent)) { scrollPositionEvent = scrollViewScope.scrollPosition; foreach (var item in viewPageItem.eventDatas.ToArray()) { using (var horizon = new EditorGUILayout.HorizontalScope("box")) { using (var vertical = new EditorGUILayout.VerticalScope()) { using (var horizon2 = new EditorGUILayout.HorizontalScope()) { Transform targetObject; if (!string.IsNullOrEmpty(item.targetTransformPath)) { targetObject = viewPageItem.viewElement.transform.Find(item.targetTransformPath); } else { targetObject = viewPageItem.viewElement.transform; } if (targetObject == null) { using (var vertical2 = new EditorGUILayout.VerticalScope()) { GUILayout.Label(new GUIContent($"Target GameObject is Missing : [{viewPageItem.viewElement.name}/{item.targetTransformPath}]", Drawer.miniErrorIcon)); item.targetTransformPath = EditorGUILayout.TextField(item.targetTransformPath); if (GUILayout.Button(new GUIContent("Remove item!"))) { viewPageItem.eventDatas.RemoveAll(m => m == item); } } continue; } UnityEngine.Object targetComponent = targetObject.GetComponent(item.targetComponentType); if (targetComponent == null) { using (var vertical2 = new EditorGUILayout.VerticalScope()) { GUILayout.Label(new GUIContent($"ComponentType : [{item.targetComponentType}] is missing!", Drawer.miniErrorIcon), GUILayout.Height(EditorGUIUtility.singleLineHeight)); GUILayout.Label(new GUIContent($"Use Toolvar>Verifiers>Verify Override to fix the problem.")); if (GUILayout.Button(new GUIContent("Remove item!"))) { viewPageItem.eventDatas.RemoveAll(m => m == item); } } continue; } using (var vertical2 = new GUILayout.VerticalScope()) { GUIContent l = new GUIContent(target.name + (string.IsNullOrEmpty(item.targetTransformPath) ? "" : ("/" + item.targetTransformPath)), EditorGUIUtility.FindTexture("Prefab Icon")); GUILayout.Label(l, GUILayout.Height(EditorGUIUtility.singleLineHeight)); // GUILayout.Label(Drawer.arrowIcon, GUILayout.Height(20)); using (var horizon3 = new GUILayout.HorizontalScope()) { GUILayout.Space(20); var _cachedContent = new GUIContent(EditorGUIUtility.ObjectContent(targetComponent, targetComponent.GetType())); GUILayout.Label(_cachedContent, GUILayout.Height(EditorGUIUtility.singleLineHeight)); } } } int currentSelectClass = 0; CMEditorLayout.GroupedPopupData[] groupDatas = null; if (!string.IsNullOrEmpty(item.scriptName) && !ViewSystemVisualEditor.classMethodInfo.TryGetValue(item.scriptName, out groupDatas)) { GUILayout.Label("Target class name not found"); } else { currentSelectClass = string.IsNullOrEmpty(item.scriptName) ? 0 : ViewSystemVisualEditor.classMethodInfo.Values.ToList().IndexOf(groupDatas); using (var check = new EditorGUI.ChangeCheckScope()) { currentSelectClass = EditorGUILayout.Popup("Event Script", currentSelectClass, ViewSystemVisualEditor.classMethodInfo.Select(m => m.Key).ToArray()); if (check.changed) { if (currentSelectClass != 0) { var c = ViewSystemVisualEditor.classMethodInfo.ElementAt(currentSelectClass); item.scriptName = c.Key; item.methodName = ""; } else { item.scriptName = ""; item.methodName = ""; } } } if (currentSelectClass != 0) { using (var check = new EditorGUI.ChangeCheckScope()) { using (var horizon2 = new EditorGUILayout.HorizontalScope()) { var c = ViewSystemVisualEditor.classMethodInfo.ElementAt(currentSelectClass).Value; var current = c.SingleOrDefault(m => m.name == item.methodName); CMEditorLayout.GroupedPopupField(item.GetHashCode(), new GUIContent("Event Method"), c, current, (select) => { item.methodName = select.name; } ); } } } } } if (GUILayout.Button(ReorderableList.defaultBehaviours.iconToolbarMinus, removeButtonStyle, GUILayout.Height(EditorGUIUtility.singleLineHeight * 2))) { viewPageItem.eventDatas.Remove(item); } } } } }