private bool DrawComparerSelection(AssertionComponent script)
        {
            if (allComparersList == null)
            {
                allComparersList = new List <Type>();
                var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (var assembly in allAssemblies)
                {
                    var types = assembly.GetTypes();
                    allComparersList.AddRange(types.Where(type => type.IsSubclassOf(typeof(ActionBase)) && !type.IsAbstract));
                }
            }
            var allComparers = allComparersList.ToArray();

            if (script.Action == null)
            {
                script.Action = (ActionBase)CreateInstance(allComparers.First());
            }

            m_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);

            script.checkMethods = (CheckMethod)EditorGUILayout.EnumMaskField(script.checkMethods,
                                                                             EditorStyles.popup,
                                                                             GUILayout.ExpandWidth(false));
            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
            }
        }
Пример #3
0
        public override void OnInspectorGUI()
        {
            var script = (AssertionComponent)target;

            EditorGUILayout.BeginHorizontal();
            var obj = DrawComparerSelection(script);

            script.checkMethods = (AssertionComponent.CheckMethod)EditorGUILayout.EnumMaskField(script.checkMethods,
                                                                                                EditorStyles.popup,
                                                                                                GUILayout.ExpandWidth(false));
            EditorGUILayout.EndHorizontal();

            if (script.IsCheckMethodSelected(AssertionComponent.CheckMethod.AfterPeriodOfTime))
            {
                DrawOptionsForAfterPeriodOfTime(script);
            }

            if (script.IsCheckMethodSelected(AssertionComponent.CheckMethod.Update))
            {
                DrawOptionsForOnUpdate(script);
            }

            if (obj)
            {
                EditorGUILayout.Space();

                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);
                }
            }
        }
 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);
        }