Ejemplo n.º 1
0
 private static void     ResetAssets()
 {
     if (HQ.settings == null)
     {
         NGEditorPrefs.DeleteKey(Constants.ConfigPathKeyPref, true);
         GUICallbackWindow.Open(() => HQ.LoadSharedNGSetting());
     }
 }
Ejemplo n.º 2
0
 public void     Save()
 {
     if (this.disabledTips.Count > 0)
     {
         NGEditorPrefs.SetString(key, string.Join(TipsHelper.Separator.ToString(), this.disabledTips.ToArray()));
     }
     else if (NGEditorPrefs.HasKey(key) == true)
     {
         NGEditorPrefs.DeleteKey(key);
     }
 }
Ejemplo n.º 3
0
        public void     EraseAll(bool silent = false)
        {
            this.disabledTips.Clear();

            if (NGEditorPrefs.HasKey(key) == true)
            {
                NGEditorPrefs.DeleteKey(key);
            }

            if (silent == false)
            {
                EditorUtility.DisplayDialog(Constants.PackageTitle, "Tips have been reset.", "OK");
            }
        }
Ejemplo n.º 4
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            Array array = instance as Array;

            if (array == null)
            {
                NGEditorPrefs.DeleteKey(path);
                return;
            }

            NGEditorPrefs.SetInt(path, array.Length);

            try
            {
                if (array.Length > 0)
                {
                    Type subType = Utility.GetArraySubType(type);

                    if (subType.IsValueType == true || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true)
                    {
                        NGEditorPrefs.SetString(path + ".serialized", Convert.ToBase64String(Utility.SerializeField(array)));
                        return;
                    }
                }

                for (int i = 0; i < array.Length; i++)
                {
                    object value = array.GetValue(i);

                    if (value != null)
                    {
                        Utility.DirectSaveEditorPref(value, value.GetType(), path + '.' + i);
                    }
                    else
                    {
                        NGEditorPrefs.DeleteKey(path + '.' + i);
                    }
                }
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException("EditorPrefArray failed saving at \"" + path + "\".", ex);
            }
        }
Ejemplo n.º 5
0
        public override void    DirectSave(object instance, Type type, string path)
        {
            IList list = instance as IList;

            if (list == null)
            {
                NGEditorPrefs.DeleteKey(path);
                return;
            }

            NGEditorPrefs.SetInt(path, list.Count);

            try
            {
                if (list.Count > 0)
                {
                    Type subType = Utility.GetArraySubType(type);

                    if ((subType.IsValueType == true && subType.IsStruct() == false) || subType == typeof(string) || subType.IsInterface == true || subType.IsAbstract == true)
                    {
                        NGEditorPrefs.SetString(path + ".serialized", Convert.ToBase64String(Utility.SerializeField(list)));
                        return;
                    }
                }

                for (int i = 0; i < list.Count; i++)
                {
                    object value = list[i];

                    if (value != null)
                    {
                        Utility.DirectSaveEditorPref(value, value.GetType(), path + '.' + i);
                    }
                    else
                    {
                        NGEditorPrefs.DeleteKey(path + '.' + i);
                    }
                }
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException("EditorPrefList failed saving at \"" + path + "\".", ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// For the curious who might want to know why I send these stats.
        /// I need some info about Unity Editor usage, especially because Unity does not provide them.
        /// In order to keep supporting old versions or platforms.
        /// </summary>
        /// <param name="sendStats"></param>
        internal static void    SendStats(bool sendStats = true)
        {
            string path     = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, "sendStats." + Utility.UnityVersion + "." + Constants.Version + ".txt"));
            bool   sentOnce = false;
            string today    = DateTime.Now.ToString("yyyyMMdd");

            if (File.Exists(path) == true)
            {
                string lastTime = File.ReadAllText(path);

                if (lastTime == today)
                {
                    sentOnce = true;
                }
            }

            if (sentOnce == false)
            {
                try
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    File.WriteAllText(path, today);
                }
                catch
                {
                    string rawSentOnceCount = HQ.GetStatsComplementary("SSSOC");
                    int    errorCount;

                    if (string.IsNullOrEmpty(rawSentOnceCount) == false && int.TryParse(rawSentOnceCount, out errorCount) == true)
                    {
                        HQ.SetStatsComplementary("SSSOC", (errorCount + 1).ToString());
                    }
                    else
                    {
                        HQ.SetStatsComplementary("SSSOC", "1");
                    }
                }
            }

            if (sentOnce == false || sendStats == false)
            {
                StringBuilder buffer = Utility.GetBuffer(HQ.ServerEndPoint + "unityeditor.php?u=");

                buffer.Append(Utility.UnityVersion);
                buffer.Append("&o=");
                buffer.Append(SystemInfo.operatingSystem);
                buffer.Append("&p=");
                buffer.Append(Constants.Version);
                buffer.Append("&n=");
                buffer.Append(SystemInfo.deviceName);
                buffer.Append("&un=");
                buffer.Append(Environment.UserName);
                buffer.Append("&ut=");
                buffer.Append(Metrics.GetUsedTools());
                Metrics.ResetUsedTools();

                buffer.Append("&m=");
                buffer.Append(HQ.GetMACAddressHash());

                foreach (License license in NGLicensesManager.EachInvoices())
                {
                    if (license.active == true && license.status != Status.Banned)
                    {
                        buffer.Append("&in[]=");
                        buffer.Append(license.invoice);
                    }
                }

                foreach (HQ.ToolAssemblyInfo tool in HQ.EachTool)
                {
                    buffer.Append("&to[]=");
                    buffer.Append(tool.name);
                    buffer.Append(":");
                    buffer.Append(tool.version);
                }

                string complementary = NGEditorPrefs.GetString(HQ.ComplementaryKeyPref);
                if (string.IsNullOrEmpty(complementary) == false)
                {
                    buffer.Append("&com=" + complementary);
                }

                if (sendStats == false)
                {
                    buffer.Append("&s");
                }

                Utility.RequestURL(Utility.ReturnBuffer(buffer), (s, r) =>
                {
                    if (s == Utility.RequestStatus.Completed)
                    {
                        NGEditorPrefs.DeleteKey(HQ.ComplementaryKeyPref);
                    }
                    else
                    {
                        string rawErrorCount = HQ.GetStatsComplementary("SSEC");
                        int errorCount;

                        if (string.IsNullOrEmpty(rawErrorCount) == false && int.TryParse(rawErrorCount, out errorCount) == true)
                        {
                            HQ.SetStatsComplementary("SSEC", (errorCount + 1).ToString());
                        }
                        else
                        {
                            HQ.SetStatsComplementary("SSEC", "1");
                        }
                    }
                });
            }
        }