void DrawExecuteStaticFunction(EventHalf action) { string[] popupArray = new string[0]; string[] popupArrayNice = new string[0]; if (EventLibrary.library.ContainsKey(action.e_classString + "Methods")) { popupArray = EventLibrary.library[action.e_classString + "Methods"]; popupArrayNice = EventLibrary.libraryNice[action.e_classString + "Methods"]; } if (popupArray.Length > 0) { EditorGUILayout.LabelField("Action Function", GUILayout.MaxWidth(columnWidth)); action.e_fieldIndex = FindIndex(action.e_fieldString, popupArray); action.e_fieldIndex = (int)EditorGUILayout.Popup(action.e_fieldIndex, popupArrayNice, GUILayout.MaxWidth(columnWidth)); action.e_fieldString = popupArray[action.e_fieldIndex]; // Determine type to pass System.Type[] paramType = new System.Type[] { typeof(void) }; if (EventLibrary.staticClasses[action.e_classString].GetMethod(action.e_fieldString) != null) { System.Reflection.ParameterInfo[] par = EventLibrary.staticClasses[action.e_classString].GetMethod(action.e_fieldString).GetParameters(); if (par.Length > 0) { paramType = new System.Type[par.Length]; } if (par.Length > 5) { Debug.LogWarning("Event functions cannot have more than 5 parameters"); return; } for (int i = 0; i < par.Length; i++) { paramType[i] = par[i].ParameterType; DrawExecuteParameter(action, paramType[i], i); } // Set the parameters action.args = action.SetParameters(paramType); } } }
void DrawExecuteStaticFunction(EventHalf action) { string[] popupArray = new string[0]; string[] popupArrayNice = new string[0]; if(EventLibrary.library.ContainsKey(action.e_classString + "Methods")) { popupArray = EventLibrary.library[action.e_classString + "Methods"]; popupArrayNice = EventLibrary.libraryNice[action.e_classString + "Methods"]; } if(popupArray.Length > 0) { EditorGUILayout.LabelField("Action Function", GUILayout.MaxWidth(columnWidth)); action.e_fieldIndex = FindIndex(action.e_fieldString, popupArray); action.e_fieldIndex = (int)EditorGUILayout.Popup(action.e_fieldIndex, popupArrayNice, GUILayout.MaxWidth(columnWidth)); action.e_fieldString = popupArray[action.e_fieldIndex]; // Determine type to pass System.Type[] paramType = new System.Type[] { typeof(void) }; if(EventLibrary.staticClasses[action.e_classString].GetMethod(action.e_fieldString) != null) { System.Reflection.ParameterInfo[] par = EventLibrary.staticClasses[action.e_classString].GetMethod(action.e_fieldString).GetParameters(); if(par.Length > 0) { paramType = new System.Type[par.Length]; } if(par.Length > 5) { Debug.LogWarning("Event functions cannot have more than 5 parameters"); return; } for(int i = 0; i < par.Length; i++) { paramType[i] = par[i].ParameterType; DrawExecuteParameter(action, paramType[i], i); } // Set the parameters action.args = action.SetParameters(paramType); } } }
void DrawExecuteFunction(EventHalf action) { string[] popupArray = new string[0]; string[] popupArrayNice = new string[0]; //action.e_classString = action.e_categoryString; if(!EventLibrary.instanceClasses[action.e_classString]) { EditorGUILayout.LabelField("Target Object", GUILayout.MaxWidth(columnWidth)); action.e_GameObject = (GameObject)EditorGUILayout.ObjectField(action.e_GameObject, typeof(GameObject), true, GUILayout.MaxWidth(columnWidth)); if(action.e_GameObject == null) { action.e_MonoBehaviour = null; } else { action.e_MonoBehaviour = action.e_GameObject.GetComponent(action.e_classString) as MonoBehaviour; } if(action.e_MonoBehaviour == null) { action.e_GameObject = null; //EditorGUILayout.LabelField("Select a GameObject with attached script:", GUILayout.MaxWidth(columnWidth)); //EditorGUILayout.LabelField("<b>" + action.e_classString + "</b>", style, GUILayout.MaxWidth(columnWidth)); //action.editorHeight += 34; } } else { //todo: instance based classes } if(action.e_MonoBehaviour != null) { action.editorHeight += 32; if(EventLibrary.library.ContainsKey(action.e_classString + "Methods")) { popupArray = EventLibrary.library[action.e_classString + "Methods"]; popupArrayNice = EventLibrary.libraryNice[action.e_classString + "Methods"]; } if(popupArray.Length > 0) { EditorGUILayout.LabelField("Action Function", GUILayout.MaxWidth(columnWidth)); action.e_fieldIndex = FindIndex(action.e_fieldString, popupArray); action.e_fieldIndex = (int)EditorGUILayout.Popup(action.e_fieldIndex, popupArrayNice, GUILayout.MaxWidth(columnWidth)); action.e_fieldString = popupArray[action.e_fieldIndex]; // Determine type to pass System.Type[] paramType = new System.Type[] { typeof(void) }; if(popupArray.Length > action.e_fieldIndex) { action.e_fieldString = popupArray[action.e_fieldIndex]; System.Reflection.ParameterInfo[] par = action.e_MonoBehaviour.GetType().GetMethod(action.e_fieldString).GetParameters(); if(par.Length > 0) { paramType = new System.Type[par.Length]; } if(par.Length > 5) { Debug.LogWarning("Event functions cannot have more than 5 parameters"); return; } for(int i = 0; i < par.Length; i++) { paramType[i] = par[i].ParameterType; DrawExecuteParameter(action, paramType[i], i); } } // Set the parameters action.args = action.SetParameters(paramType); } else { EditorGUILayout.LabelField("<b>No Valid Methods</b>", style, GUILayout.MaxWidth(columnWidth)); } } }
void DrawExecuteFunction(EventHalf action) { string[] popupArray = new string[0]; string[] popupArrayNice = new string[0]; //action.e_classString = action.e_categoryString; if (!EventLibrary.instanceClasses[action.e_classString]) { EditorGUILayout.LabelField("Target Object", GUILayout.MaxWidth(columnWidth)); action.e_GameObject = (GameObject)EditorGUILayout.ObjectField(action.e_GameObject, typeof(GameObject), true, GUILayout.MaxWidth(columnWidth)); if (action.e_GameObject == null) { action.e_MonoBehaviour = null; } else { action.e_MonoBehaviour = action.e_GameObject.GetComponent(action.e_classString) as MonoBehaviour; } if (action.e_MonoBehaviour == null) { action.e_GameObject = null; //EditorGUILayout.LabelField("Select a GameObject with attached script:", GUILayout.MaxWidth(columnWidth)); //EditorGUILayout.LabelField("<b>" + action.e_classString + "</b>", style, GUILayout.MaxWidth(columnWidth)); //action.editorHeight += 34; } } else { //todo: instance based classes } if (action.e_MonoBehaviour != null) { action.editorHeight += 32; if (EventLibrary.library.ContainsKey(action.e_classString + "Methods")) { popupArray = EventLibrary.library[action.e_classString + "Methods"]; popupArrayNice = EventLibrary.libraryNice[action.e_classString + "Methods"]; } if (popupArray.Length > 0) { EditorGUILayout.LabelField("Action Function", GUILayout.MaxWidth(columnWidth)); action.e_fieldIndex = FindIndex(action.e_fieldString, popupArray); action.e_fieldIndex = (int)EditorGUILayout.Popup(action.e_fieldIndex, popupArrayNice, GUILayout.MaxWidth(columnWidth)); action.e_fieldString = popupArray[action.e_fieldIndex]; // Determine type to pass System.Type[] paramType = new System.Type[] { typeof(void) }; if (popupArray.Length > action.e_fieldIndex) { action.e_fieldString = popupArray[action.e_fieldIndex]; System.Reflection.ParameterInfo[] par = action.e_MonoBehaviour.GetType().GetMethod(action.e_fieldString).GetParameters(); if (par.Length > 0) { paramType = new System.Type[par.Length]; } if (par.Length > 5) { Debug.LogWarning("Event functions cannot have more than 5 parameters"); return; } for (int i = 0; i < par.Length; i++) { paramType[i] = par[i].ParameterType; DrawExecuteParameter(action, paramType[i], i); } } // Set the parameters action.args = action.SetParameters(paramType); } else { EditorGUILayout.LabelField("<b>No Valid Methods</b>", style, GUILayout.MaxWidth(columnWidth)); } } }