Exemple #1
0
        private void CopyToNew(MachineConfig config)
        {
            string dir      = EditorUtilityEx.GetSelectDirectory();
            string filePath = EditorUtilityEx.ValidFilePath(Path.Combine(dir, "MachineConfig.bytes"));
            string data     = DataUtility.ToJson(config);

            File.WriteAllText(filePath, data);
            AssetDatabase.Refresh();

            Debug.Log($"配置已拷贝到 : {filePath}");
        }
Exemple #2
0
        private void CreateNew()
        {
            string dir      = EditorUtilityEx.GetSelectDirectory();
            string filePath = EditorUtilityEx.ValidFilePath(Path.Combine(dir, "MachineConfig.bytes"));
            string data     = DataUtility.ToJson(new MachineConfig());

            File.WriteAllText(filePath, data);
            Debug.Log($"配置已创建到 : {filePath}");
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            win.configAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(filePath);
            win.UpdateConfig(win.configAsset);
        }