private void DrawObjectCompareField(ComparerBase comparer) { otherPathSelector.Draw(comparer.other, comparer, comparer.otherPropertyPath, comparer.GetAccepatbleTypesForB(), go => { comparer.other = go; AssertionExplorerWindow.Reload(); }, s => { comparer.otherPropertyPath = s; AssertionExplorerWindow.Reload(); } ); }
private bool DrawComparerSelection(AssertionComponent script) { var types = typeof(ActionBase).Assembly.GetTypes(); var allComparers = types.Where(type => type.IsSubclassOf(typeof(ActionBase)) && !type.IsAbstract).ToArray(); if (script.Action == null) { script.Action = (ActionBase)CreateInstance(allComparers.First()); } comparerDropDown.Draw(script.Action.GetType(), allComparers, type => { if (script.Action == null || script.Action.GetType().Name != type.Name) { script.Action = (ActionBase)CreateInstance(type); AssertionExplorerWindow.Reload(); } }); return(script.Action != null); }
public override void OnInspectorGUI() { var script = (AssertionComponent)target; EditorGUILayout.BeginHorizontal(); var obj = DrawComparerSelection(script); #if UNITY_2017_3_OR_NEWER script.checkMethods = (CheckMethod)EditorGUILayout.EnumFlagsField(script.checkMethods, EditorStyles.popup, GUILayout.ExpandWidth(false)); #else script.checkMethods = (CheckMethod)EditorGUILayout.EnumMaskField(script.checkMethods, EditorStyles.popup, GUILayout.ExpandWidth(false)); #endif EditorGUILayout.EndHorizontal(); if (script.IsCheckMethodSelected(CheckMethod.AfterPeriodOfTime)) { DrawOptionsForAfterPeriodOfTime(script); } if (script.IsCheckMethodSelected(CheckMethod.Update)) { DrawOptionsForOnUpdate(script); } if (obj) { EditorGUILayout.Space(); m_ThisPathSelector.Draw(script.Action.go, script.Action, script.Action.thisPropertyPath, script.Action.GetAccepatbleTypesForA(), go => { script.Action.go = go; AssertionExplorerWindow.Reload(); }, s => { script.Action.thisPropertyPath = s; AssertionExplorerWindow.Reload(); }); EditorGUILayout.Space(); DrawCustomFields(script); EditorGUILayout.Space(); if (script.Action is ComparerBase) { DrawCompareToType(script.Action as ComparerBase); } } if (GUI.changed) { #if UNITY_5_3_OR_NEWER EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); #else EditorApplication.MarkSceneDirty(); #endif } }