Esempio n. 1
0
        private void DrawDebug()
        {
            GUILayout.Space(150);
            debugEditorFoldout = EditorGUILayout.Foldout(debugEditorFoldout, "< Debug >");
            if (debugEditorFoldout)
            {
                //  -- Debug
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button(" Print Root Selector ", EditorStyles.miniButton, GUILayout.Height(18)))
                    {
                        Debug.Log(currentClient.configuration.rootSelector + "\n" + currentClient.configuration.rootSelector.qualifiers.Count);
                        //Debug.Log(currentClient.configuration.selector + "\n" + currentClient.configuration.selector.qualifiers.Count);
                        //Debug.Log(serializedObject.FindProperty("configuration.selector").type);
                    }

                    if (GUILayout.Button("Debug AI RootSelector Properties", EditorStyles.miniButton, GUILayout.Height(18)))
                    {
                        Debug.Log("Active Client" + currentClient.configuration.rootSelector.GetType());
                        var entity = currentClient.configuration.rootSelector;
                        var obj    = TaskNetworkUtilities.GetAllProperties(entity);
                        foreach (PropertyInfo info in obj)
                        {
                            //info.GetValue(entity);
                            //Debug.Log(info.GetValue(entity).GetType());
                            //Debug.Log(info.GetValue(entity));
                        }
                    }
                }

                EditorGUILayout.Space();
                //string selectorConfigInfo = currentClient != null ? DebugEditorUtilities.SelectorConfig(currentClient.configuration.selector) : "No Selected Selector";
                string selectorConfigInfo = currentClient != null?DebugEditorUtilities.SelectorConfig(currentClient.configuration.rootSelector) : "No Selected Selector";

                EditorGUILayout.HelpBox(selectorConfigInfo, MessageType.Info);
            }
        }
Esempio n. 2
0
        void AIReflection()
        {
            //if (GUILayout.Button("Debug AI RootSelector Properties")){
            //    var utilityAI = currentClient.configuration.rootSelector;
            //    var obj = TaskNetworkUtilities.GetAllProperties(utilityAI);
            //    foreach (PropertyInfo info in obj){
            //        Debug.Log(info.GetValue(utilityAI));
            //    }
            //}
            if (currentClient == null)
            {
                return;
            }

            var utilityAI = currentClient.configuration.rootSelector;


            PropertyInfo[] properties = TaskNetworkUtilities.GetAllProperties(utilityAI);
            foreach (PropertyInfo property in properties)
            {
                string displayInfo = "";


                //  Name of the property.
                string propertyName = property.Name;
                //  Property type.
                Type propertyType = property.PropertyType;
                //  What class it was declared in.
                Type declaringType = property.DeclaringType;
                //IEnumerable<CustomAttributeData> customAttributes = property.CustomAttributes;
                //  If it is a property, field or method.
                MemberTypes memberType = property.MemberType;
                object      getValue   = property.GetValue(utilityAI, null);
                ICollection collection = getValue as ICollection;

                int?   count;
                string countString     = "";
                string collectionItems = "";
                string itemInfoString  = "";

                if (collection != null)
                {
                    count       = collection.Count;
                    countString = "(Count: " + count + ")";
                    if (getValue is IEnumerable)
                    {
                        collectionItems += "  Collection Items\n";
                        IList list  = getValue as IList;
                        int   index = 0;
                        foreach (object obj in list)
                        {
                            itemInfoString += "    " + obj.GetType() + "(" + index + ")\n";
                            PropertyInfo[] itemInfo = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                            foreach (PropertyInfo item in itemInfo)
                            {
                                itemInfoString += string.Format("      Property Name:     {0}\n" +
                                                                "      Property Type:     {1}\n" +
                                                                "      Property GetValue: {2}\n\n",
                                                                item.Name, item.PropertyType, item.GetValue(obj, null));
                            }
                            //FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                            //foreach (FieldInfo item in fields)
                            //{
                            //    itemInfoString += string.Format("      Field Name:     {0}\n" +
                            //                                    "      Field Type:     {1}\n" +
                            //                                    "      Field GetValue: {2}\n\n",
                            //                                    item.Name, item.FieldType, item.GetValue(obj));
                            //}
                            index++;
                            collectionItems += itemInfoString + "\n";
                        }
                    }

                    //for (int i = 0; i < count; i ++){
                    //    object item = property.GetValue(utilityAI, new object[] { i });
                    //    collectionItems += "    " + item.GetType().Name + "\n";
                    //}
                }
                else
                {
                    count       = null;
                    countString = "<None>";
                }


                displayInfo = string.Format("Property Name:     {0}\n" +
                                            "Property Type:     {1}\n" +
                                            "Declaring Type:    {2}\n" +
                                            "Custom Attributes: {3}\n" +
                                            "Property GetValue: {4} ({7})| {5}\n" +
                                            "{6}\n",
                                            propertyName, propertyType, declaringType, "<None>", getValue, countString, collectionItems, getValue.GetType());

                GUILayout.Label(displayInfo);
            }
        }