private void SaveAsset(ConfigAsset asset) { asset.Save(configs); EditorUtility.SetDirty(asset); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public void DrawGraph(ConfigAssetGroup groupAsset, ConfigAsset asset) { GUILayoutExtension.HorizontalGroup(() => { EditorGUILayout.LabelField(asset.name, GUILayout.Width(150)); if (GUILayout.Button("打开", GUILayout.Width(50))) { ConfigAssetWindow.Open(asset); } if (GUILayout.Button("删除", GUILayout.Width(50))) { groupAsset.RemoveAsset(asset); } if (GUILayout.Button("重命名", GUILayout.Width(50))) { MiscHelper.Input($"输入配置名:", (string name) => { asset.name = name; EditorUtility.SetDirty(asset); EditorUtility.SetDirty(target); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }); } }); }
public void RemoveAsset(ConfigAsset asset) { DestroyImmediate(asset, true); EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public static ConfigAssetWindow Open(ConfigAsset asset) { if (asset == null) { return(null); } var window = GetWindow <ConfigAssetWindow>(); window.titleContent = new GUIContent($"ÅäÖÃ:{asset.name}"); window.currSelAsset = asset; window.ChangeSelAsset(asset); return(window); }
public List <ConfigAsset> GetAllAsset() { List <ConfigAsset> assets = new List <ConfigAsset>(); Object[] objs = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(this)); for (int i = 0; i < objs.Length; i++) { if (objs[i] is ConfigAsset) { ConfigAsset asset = (ConfigAsset)objs[i]; asset.cnfTypeFullName = configTypeFullName; assets.Add(asset); } } return(assets); }
public bool CreateAsset(string name) { if (CheckHasAsset(name)) { Debug.LogError($"创建资源失败,重复资源>>{name}"); return(false); } ConfigAsset asset = CreateInstance <ConfigAsset>(); asset.name = name; asset.cnfTypeFullName = configTypeFullName; AssetDatabase.AddObjectToAsset(asset, this); EditorUtility.SetDirty(asset); EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); return(true); }
public void ChangeSelAsset(ConfigAsset asset) { configs.Clear(); fields.Clear(); fieldRects.Clear(); SelConfigs.Clear(); CommandDispacter = new CommandDispatcher(); currSelAsset = asset; List <IConfig> tmpConfigs = currSelAsset.Load(); if (tmpConfigs == null) { configs = new List <IConfig>(); configs.Add(currSelAsset.CreateCnfItem()); } else { configs = tmpConfigs; } GetFields(); }