Ejemplo n.º 1
0
        internal static void    SetSendStats(object sendStats)
        {
            if ((bool)sendStats == false)
            {
                if (EditorUtility.DisplayDialog(Constants.PackageTitle, "For those who might want to know why I send stats.\nI need some info about Unity Editor usage, especially because Unity does not provide them.\nIn order to keep supporting legacy versions, unused tools or platforms such as Unity 4, Mac or else.\n\nDo you confirm not sending stats?", "Yes", "No") == false)
                {
                    return;
                }

                HQ.SendStats(false);
            }

            NGEditorPrefs.SetBool(HQ.AllowSendStatsKeyPref, (bool)sendStats);
        }
Ejemplo n.º 2
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;
        }