コード例 #1
0
        public void     Init(Client client, int parentInstanceID, int instanceID, ClientMethod method)
        {
            this.client           = client;
            this.parentInstanceID = parentInstanceID;
            this.instanceID       = instanceID;
            this.method           = method;

            this.drawers = new ArgumentDrawer[this.method.argumentNames.Length];

            if (MethodArgumentsWindow.types == null)
            {
                MethodArgumentsWindow.types = new DynamicOrderedArray <Type>(Utility.GetAllSubClassesOf(typeof(ArgumentDrawer)));
            }

            for (int i = 0; i < this.method.argumentTypes.Length; i++)
            {
                for (int j = 0; j < MethodArgumentsWindow.types.array.Length; j++)
                {
                    ArgumentDrawerFor[] attribute = MethodArgumentsWindow.types.array[j].GetCustomAttributes(typeof(ArgumentDrawerFor), false) as ArgumentDrawerFor[];

                    if (attribute.Length > 0)
                    {
                        if (attribute[0].type.IsAssignableFrom(this.method.argumentTypes[i]) == true)
                        {
                            this.drawers[i] = Activator.CreateInstance(MethodArgumentsWindow.types.array[j], this.method.argumentNames[i], this.method.argumentTypes[i]) as ArgumentDrawer;
                            this.drawers[i].Load(this.method.name + "." + this.method.argumentNames[i]);
                            MethodArgumentsWindow.types.BringToTop(j);
                            break;
                        }
                    }
                }
            }

            this.invokeFeedbackAnim = new BgColorContentAnimator(this.Repaint, 1F, 0F);
        }
コード例 #2
0
        public void     ResolveReferences(ICollection <TypeReference> types, ICollection <FieldReference> fields, ICollection <MethodReference> methods)
        {
            int assembliesMetaLength = this.unityMeta.AssembliesMeta.Length;
            DynamicOrderedArray <AssemblyMeta> assemblies = new DynamicOrderedArray <AssemblyMeta>(this.unityMeta.AssembliesMeta);

            foreach (TypeReference typeRef in types)
            {
                TypeMeta meta = null;
                int      j    = 0;

                for (; j < assembliesMetaLength && meta == null; ++j)
                {
                    meta = assemblies.array[j].Resolve(typeRef);
                }

                if (meta != null)
                {
                    assemblies.BringToTop(j - 1);

                    if (meta.ErrorMessage != null)
                    {
                        this.foundTypes.Add(meta);
                    }
                }
                else
                {
                    // Type not found, maybe look into other types. Might be renamed.
                    TypeMeta lastFound        = null;
                    string   typeRefNamespace = typeRef.Namespace;
                    string   typeRefName      = typeRef.Name;

                    j = 0;

                    for (; j < assembliesMetaLength && lastFound == null; ++j)
                    {
                        for (int k = 0, max = assemblies.array[j].Types.Length; k < max; ++k)
                        {
                            TypeMeta typeMeta = assemblies.array[j].Types[k];

                            if (typeMeta.Name == typeRefName)
                            {
                                if (lastFound == null || this.GetLevenshteinDistance(lastFound.Namespace, typeRefNamespace) > this.GetLevenshteinDistance(typeMeta.Namespace, typeRefNamespace))
                                {
                                    lastFound = typeMeta;
                                    break;
                                }
                            }
                        }
                    }

                    if (lastFound != null)
                    {
                        this.missingTypes.Add(new TypeMeta(typeRef, "Type not found, but a similar Type has been found at \"" + lastFound.FullName + "\"."));
                    }
                    else
                    {
                        this.missingTypes.Add(new TypeMeta(typeRef));
                    }
                }
            }

            foreach (FieldReference fieldRef in fields)
            {
                FieldMeta meta = null;
                int       j    = 0;

                for (; j < assembliesMetaLength && meta == null; ++j)
                {
                    meta = assemblies.array[j].Resolve(fieldRef);
                }

                if (meta != null)
                {
                    assemblies.BringToTop(j - 1);

                    if (meta.ErrorMessage != null)
                    {
                        this.foundFields.Add(meta);
                    }
                }
                else
                {
                    this.missingFields.Add(new FieldMeta(fieldRef));
                }
            }

            foreach (MethodReference methodRef in methods)
            {
                MethodMeta meta = null;
                int        j    = 0;

                for (; j < assembliesMetaLength && meta == null; ++j)
                {
                    meta = assemblies.array[j].Resolve(methodRef);
                }

                if (meta != null)
                {
                    assemblies.BringToTop(j - 1);

                    if (meta.ErrorMessage != null)
                    {
                        this.foundMethods.Add(meta);
                    }
                }
                else
                {
                    this.missingMethods.Add(new MethodMeta(methodRef));
                }
            }
        }
コード例 #3
0
        private ScriptableObject        Load(Type type)
        {
            if (this.subAssets == null || this.subAssets.array == null)
            {
                if (HQ.UsingEditorSettings == true)
                {
                    NGSettings.CheckProjectCredentialsSettings();
                    this.subAssets = new DynamicOrderedArray <Object>(InternalEditorUtility.LoadSerializedFileAndForget(NGSettings.GetSharedSettingsPath()));
                }
                else
                {
                    this.subAssets = new DynamicOrderedArray <Object>(AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(HQ.Settings)));
                }

                this.CheckAssets();
            }

            for (int i = 0; i < this.subAssets.array.Length; i++)
            {
                if (this.subAssets.array[i].GetType() == type)
                {
                    this.lastSubAsset = this.subAssets.array[i] as ScriptableObject;
                    this.subAssets.BringToTop(i);
                    return(this.lastSubAsset);
                }
            }

            ScriptableObject newInstance = ScriptableObject.CreateInstance(type);

            newInstance.name      = type.FullName;
            newInstance.hideFlags = HideFlags.DontSave;

            Object[] newSubAssets;

            if (this.subAssets.array.Length == 0)
            {
                newSubAssets = new Object[] { this, newInstance }
            }
            ;
            else
            {
                newSubAssets = new Object[this.subAssets.array.Length + 1];

                Array.Copy(this.subAssets.array, newSubAssets, this.subAssets.array.Length);
                newSubAssets[this.subAssets.array.Length] = newInstance;
            }

            this.subAssets.array = newSubAssets;
            this.lastSubAsset    = newInstance;

            if (HQ.UsingEditorSettings == true)
            {
                this.SaveSharedSettings();
            }
            else
            {
                // Unity 2017 does not like DontSave flag.
                newInstance.hideFlags = HideFlags.None;
                AssetDatabase.AddObjectToAsset(newInstance, HQ.Settings);
                newInstance.hideFlags = HideFlags.DontSave;

                // This is to prevent "Assertion failed on expression: '!m_IsGettingEntries'". Because NG Console can request its settings in SyncLogs, which is getting entries.
                EditorApplication.delayCall -= AssetDatabase.SaveAssets;
                EditorApplication.delayCall += AssetDatabase.SaveAssets;
            }

            if (NGSettings.lazySettingsCallbacksLoaded == false)
            {
                NGSettings.lazySettingsCallbacksLoaded = true;

                foreach (Type t in Utility.EachNGTSubClassesOf(typeof(object)))
                {
                    MethodInfo[] methods = t.GetMethods(BindingFlags.NonPublic | BindingFlags.Static);

                    for (int i = 0; i < methods.Length; i++)
                    {
                        if (methods[i].IsDefined(typeof(NGSettingsChangedAttribute), false) == true)
                        {
                            NGSettings.SettingsGenerated += Delegate.CreateDelegate(typeof(Action <ScriptableObject>), null, methods[i]) as Action <ScriptableObject>;
                            break;
                        }
                    }
                }
            }

            if (NGSettings.SettingsGenerated != null)
            {
                NGSettings.SettingsGenerated(newInstance);
            }

            return(newInstance);
        }