Esempio n. 1
0
        private void OnGUI()
        {
            UPRGUIUtil.GUI_Title("UPRTools", packageVersion);

            using (new EditorGUI.DisabledScope(EditorApplication.isCompiling))
            {
                bool tempUPRdirty = false;
                GUI_AssetProfiler(ref tempUPRdirty);

                GUILayout.Space(10);
                GUI_LuaProfiler(ref tempUPRdirty);

                //save dirtys;
                if (tempUPRdirty)
                {
                    _UPRSetting.Save();
                }
            }

            UPRGUIUtil.GUI_Bottom(this);
        }
Esempio n. 2
0
        public static UPRToolSetting Load()
        {
            UPRToolSetting uprToolSetting = new UPRToolSetting();

            byte[] datas = null;
    #if UNITY_EDITOR
            string text = "Assets/UPRTools/Resources/UPRToolSettings.bytes";
            if (!File.Exists(text))
            {
                uprToolSetting.Save();
            }
            datas = File.ReadAllBytes(text);
    #else
            TextAsset textAsset = null;
            string    path      = Application.persistentDataPath + "/UPRToolSettings.bytes";
            if (File.Exists(path))
            {
                datas = File.ReadAllBytes(path);
            }
            else
            {
                textAsset = Resources.Load <TextAsset>("UPRToolSettings");
                datas     = textAsset != null ? textAsset.bytes : null;
            }
    #endif

            if (datas != null)
            {
                MemoryStream memoryStream = new MemoryStream(datas);
                try
                {
                    BinaryReader binaryReader = new BinaryReader(memoryStream);
                    uprToolSetting.m_enableLuaProfiler  = binaryReader.ReadBoolean();
                    uprToolSetting.m_enableMonoProfiler = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadScene          = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadAsset          = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadAssetBundle    = binaryReader.ReadBoolean();
                    uprToolSetting.m_instantiate        = binaryReader.ReadBoolean();
                    binaryReader.Close();
                }
                catch
                {
    #if UNITY_EDITOR
                    memoryStream.Dispose();
                    File.Delete(text);
                    return(UPRToolSetting.Load());
    #endif
                }
            }
            else
            {
                uprToolSetting.Save();
            }

    #if !UNITY_EDITOR
            if (!File.Exists(path))
            {
                File.WriteAllBytes(path, datas);
            }
            if (textAsset != null)
            {
                Resources.UnloadAsset(textAsset);
            }
    #endif

            return(uprToolSetting);
        }