Example #1
0
 public EditorPrefGUIStyle()
 {
     this.fields = new PropertyModifier[] {
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "name", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "normal", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "hover", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "active", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "focused", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "onNormal", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "onHover", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "onActive", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "onFocused", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "border", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "margin", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "padding", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "overflow", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "font", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "fontSize", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "fontStyle", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "alignment", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "wordWrap", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "richText", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "clipping", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "imagePosition", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "contentOffset", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "fixedWidth", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "fixedHeight", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "stretchWidth", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyle), "stretchHeight", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
     };
 }
 public EditorPrefGUIStyleState()
 {
     this.fields = new PropertyModifier[] {
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyleState), "background", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
         new PropertyModifier(UnityAssemblyVerifier.TryGetProperty(typeof(GUIStyleState), "textColor", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)),
     };
 }
Example #3
0
        public static Type                      TryGetNestedType(Type type, string subTypeName, BindingFlags bindingFlags)
        {
            Type result = type.GetNestedType(subTypeName, bindingFlags);

            if (result == null)
            {
                UnityAssemblyVerifier.OpenWindow(type.FullName, subTypeName);
            }

            return(result);
        }
Example #4
0
        public static MethodInfo        TryGetMethod(Type type, string methodName, Type[] arguments)
        {
            MethodInfo result = type.GetMethod(methodName, arguments);

            if (result == null)
            {
                UnityAssemblyVerifier.OpenWindow(type.FullName, methodName);
            }

            return(result);
        }
Example #5
0
        public static PropertyInfo      TryGetProperty(Type type, string propertyName, BindingFlags bindingFlags)
        {
            PropertyInfo result = type.GetProperty(propertyName, bindingFlags);

            if (result == null)
            {
                UnityAssemblyVerifier.OpenWindow(type.FullName, propertyName);
            }

            return(result);
        }
Example #6
0
        public static FieldInfo         TryGetField(Type type, string fieldName, BindingFlags bindingFlags)
        {
            FieldInfo result = type.GetField(fieldName, bindingFlags);

            if (result == null)
            {
                UnityAssemblyVerifier.OpenWindow(type.FullName, fieldName);
            }

            return(result);
        }
Example #7
0
        public static Type                      TryGetType(Assembly assembly, string type)
        {
            Type result = assembly.GetType(type);

            if (result == null)
            {
                UnityAssemblyVerifier.OpenWindow(assembly.FullName, type);
            }

            return(result);
        }
Example #8
0
        protected virtual void  OnEnable()
        {
            Utility.LoadEditorPref(this);

            if (string.IsNullOrEmpty(this.contactName) == true ||
                string.IsNullOrEmpty(this.contactEMail) == true)
            {
                try
                {
                    Type         UnityConnect = UnityAssemblyVerifier.TryGetType(typeof(Editor).Assembly, "UnityEditor.Connect.UnityConnect");
                    FieldInfo    s_Instance   = UnityAssemblyVerifier.TryGetField(UnityConnect, "s_Instance", BindingFlags.Static | BindingFlags.NonPublic);
                    PropertyInfo userInfo     = UnityAssemblyVerifier.TryGetProperty(UnityConnect, "userInfo", BindingFlags.Instance | BindingFlags.Public);
                    //PropertyInfo	projectInfo = UnityAssemblyVerifier.TryGetProperty(UnityConnect, "projectInfo", BindingFlags.Instance | BindingFlags.Public);
                    //PropertyInfo	connectInfo = UnityAssemblyVerifier.TryGetProperty(UnityConnect, "connectInfo", BindingFlags.Instance | BindingFlags.Public);

                    object UnityConnectInstance = s_Instance.GetValue(null);
                    object ui       = userInfo.GetValue(UnityConnectInstance, null);
                    Type   UserInfo = UnityAssemblyVerifier.TryGetType(typeof(Editor).Assembly, "UnityEditor.Connect.UserInfo");

                    //NGDebug.Snapshot(UnityConnectInstance);
                    //NGDebug.Snapshot(ui);
                    //NGDebug.Snapshot(projectInfo.GetValue(UnityConnectInstance, null));
                    //NGDebug.Snapshot(connectInfo.GetValue(UnityConnectInstance, null));

                    if (string.IsNullOrEmpty(this.contactName) == true)
                    {
                        FieldInfo displayName = UnityAssemblyVerifier.TryGetField(UserInfo, "m_DisplayName", BindingFlags.Instance | BindingFlags.NonPublic);
                        this.contactName = displayName.GetValue(ui) as string;
                    }

                    if (string.IsNullOrEmpty(this.contactEMail) == true)
                    {
                        FieldInfo m_UserName = UnityAssemblyVerifier.TryGetField(UserInfo, "m_UserName", BindingFlags.Instance | BindingFlags.NonPublic);
                        this.contactEMail = m_UserName.GetValue(ui) as string;
                    }
                }
                catch
                {
                }
            }
        }
        static RootGameObjectsManager()
        {
            // TODO Unity <5.6 backward compatibility?
            MethodInfo ResetRootObjectsMethod = typeof(RootGameObjectsManager).GetMethod("ResetRootObjects", BindingFlags.Static | BindingFlags.NonPublic);

            try
            {
                EventInfo hierarchyChangedEvent = typeof(EditorApplication).GetEvent("hierarchyChanged");
                hierarchyChangedEvent.AddEventHandler(null, Delegate.CreateDelegate(hierarchyChangedEvent.EventHandlerType, null, ResetRootObjectsMethod));
                //EditorApplication.hierarchyChanged += RootGameObjectsManager.ResetRootObjects;
            }
            catch
            {
                FieldInfo hierarchyWindowChangedField = UnityAssemblyVerifier.TryGetField(typeof(EditorApplication), "hierarchyWindowChanged", BindingFlags.Static | BindingFlags.Public);
                if (hierarchyWindowChangedField != null)
                {
                    hierarchyWindowChangedField.SetValue(null, Delegate.Combine((Delegate)hierarchyWindowChangedField.GetValue(null), Delegate.CreateDelegate(hierarchyWindowChangedField.FieldType, null, ResetRootObjectsMethod)));
                }
                //EditorApplication.hierarchyWindowChanged += RootGameObjectsManager.ResetRootObjects;
            }

            NGEditorApplication.ChangeScene += RootGameObjectsManager.ClearRootGameObjects;
        }
Example #10
0
        static HQ()
        {
            HQ.rootPath = Utility.GetPackagePath();
            NGDiagnostic.Log(Preferences.Title, "RootPath", HQ.RootPath);

            if (HQ.RootPath == string.Empty)
            {
                InternalNGDebug.LogWarning(Constants.RootFolderName + " folder was not found.");
                return;
            }

            HQ.SettingsChanged += HQ.CheckSettingsVersion;

            string[] files = Directory.GetFiles(HQ.RootPath, HQ.NestedNGMenuItems, SearchOption.AllDirectories);
            if (files.Length == 1)
            {
                HQ.rootedMenuFilePath = files[0];
            }

            NGLicensesManager.LicensesLoaded += () =>
            {
                NGDiagnostic.Log(Preferences.Title, "AllowSendStats", NGEditorPrefs.GetBool(HQ.AllowSendStatsKeyPref, true));
                if (NGEditorPrefs.GetBool(HQ.AllowSendStatsKeyPref, true) == true)
                {
                    HQ.SendStats();
                }
            };
            NGLicensesManager.ActivationSucceeded += (invoice) =>
            {
                string path = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, "sendStats." + Utility.UnityVersion + "." + Constants.Version + ".txt"));

                if (File.Exists(path) == true)
                {
                    File.Delete(path);
                }
            };

            //Conf.DebugMode = (Conf.DebugState)EditorPrefs.GetInt(Conf.DebugModeKeyPref, (int)Conf.DebugMode);
            Utility.SafeDelayCall(() =>
            {
                NGLicensesManager.Title            = Constants.PackageTitle;
                NGLicensesManager.IntermediatePath = Constants.InternalPackageTitle;

                NGDiagnostic.Log(Preferences.Title, "LogPath", InternalNGDebug.LogPath);
            });

            NGDiagnostic.Log(Preferences.Title, "DebugMode", Conf.DebugMode);

            // TODO Unity <5.6 backward compatibility?
            MethodInfo ResetAssetsMethod = typeof(HQ).GetMethod("ResetAssets", BindingFlags.Static | BindingFlags.NonPublic);

            try
            {
                EventInfo projectChangedEvent = typeof(EditorApplication).GetEvent("projectChanged");
                projectChangedEvent.AddEventHandler(null, Delegate.CreateDelegate(projectChangedEvent.EventHandlerType, null, ResetAssetsMethod));
                //EditorApplication.projectChanged += HQ.ResetAssets;
            }
            catch
            {
                FieldInfo projectWindowChangedField = UnityAssemblyVerifier.TryGetField(typeof(EditorApplication), "projectWindowChanged", BindingFlags.Static | BindingFlags.Public);
                if (projectWindowChangedField != null)
                {
                    projectWindowChangedField.SetValue(null, Delegate.Combine((Delegate)projectWindowChangedField.GetValue(null), Delegate.CreateDelegate(projectWindowChangedField.FieldType, null, ResetAssetsMethod)));
                }
                //EditorApplication.projectWindowChanged += HQ.ResetAssets;
            }

            EditorApplication.projectWindowItemOnGUI += ProjectCopyAssets.OnProjectElementGUI;
        }