Example #1
0
        public static void OpenWindow(DeviceModelConfig deviceModelConfig)
        {
            if (deviceModelConfig == null)
            {
                return;
            }

            DeviceModelConfigEditorWindow window = GetWindow <DeviceModelConfigEditorWindow>(true, "Device Model Config Editor");

            window.m_Config = deviceModelConfig;
            window.minSize  = new Vector2(460f, 400f);
        }
        public static void SaveAssets()
        {
#if UNITY_5_5_OR_NEWER
            DeviceModelConfig dmc = ScriptableObject.CreateInstance <DeviceModelConfig>();
            AssetDatabase.CreateAsset(dmc, "Assets/DeviceModelConfig.asset");

            AssetDatabase.SaveAssets();
#else
            EditorApplication.SaveAssets();
#endif
            Debug.Log("You have saved the serializable assets in the project.");
        }
        public static void CreateDeviceModelConfigAsset()
        {
            string path = "Assets/GameMain/Configs/DeviceModelConfig.asset";

            if (File.Exists(Path.Combine(Application.dataPath, "GameMain/Configs/DeviceModelConfig.asset")))
            {
                Debug.LogFormat("{0} 文件存在,要创建请先删除原文件", path);
                return;
            }
            DeviceModelConfig scriptableObj = ScriptableObject.CreateInstance <DeviceModelConfig>();

            AssetDatabase.CreateAsset(scriptableObj, path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
        //[MenuItem(CreateModelConfig, false)]
        public static void CreateDeviceModelConfig()
        {
            //目录
            string directory = Path.GetDirectoryName(s_ConfigFullPath);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
                AssetDatabase.Refresh();        //刷新
            }

            //创建
            DeviceModelConfig config = CreateInstance <DeviceModelConfig>();

            AssetDatabase.CreateAsset(config, "Assets/" + s_ConfigPathName);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            Debug.Log("成功创建设备模型配置");
        }