public static void SelectEntityParam() { Selection.selectionChanged = () => { if (Application.isPlaying) { if (Selection.activeGameObject != null) { if (uint.TryParse(Selection.activeGameObject.name, out uint id)) { BattleEntity entity = BattleManager.Instance.GetEntity(id); if (entity != null) { var window = GetWindow <EntityParamWindow>(); if (window != null && window.config == entity.config) { return; } BattleManager.Instance.GetParam(entity.config, (param) => { TreeNodeGraph graph = TreeNodeGraph.CreateGraph(param); if (graph != null) { window = Open <EntityParamWindow>(graph); window.config = entity.config; } }); } } } } }; }
private static TreeNodeGraph CreateTemplate() { var modelParam = new EntityParamModel(); modelParam.rect = new Rect(20, 20, TreeNode.WIDTH, TreeNode.HEIGHT); var actionParam = new EntityParamAction(); actionParam.rect = new Rect(300, 20, TreeNode.WIDTH, TreeNode.HEIGHT); modelParam.AddChild(actionParam); var animationParam = new EntityParamAnimation(); animationParam.rect = new Rect(600, 20, TreeNode.WIDTH, TreeNode.HEIGHT); modelParam.AddChild(animationParam); return(TreeNodeGraph.CreateGraph(modelParam)); }
private static bool OnOpeEntityParam(int instanceID, int line) { var asset = EditorUtility.InstanceIDToObject(instanceID) as TextAsset; if (asset != null) { EntityParam param = EntityParam.Create(asset.text); if (param != null) { TreeNodeGraph graph = TreeNodeGraph.CreateGraph(param); if (graph != null) { Open <EntityParamWindow>(graph); return(true); } } } return(false); }
protected override TreeNodeGraph OnLoad() { string path = EditorUtility.OpenFilePanel("Select a config", Application.dataPath + "/Resources/r/config/", "txt"); if (string.IsNullOrEmpty(path)) { return(null); } Debug.Log(path); string text = File.ReadAllText(path); EntityParam param = EntityParam.Create(text); if (param != null) { return(TreeNodeGraph.CreateGraph(param)); } return(base.OnLoad()); }