private string PreSaveData() { string skp = XEditorLibrary.GetPath("Skill" + "/" + _directory) + _name + ".txt"; string config = XEditorLibrary.GetEditorBasedPath("Skill" + "/" + _directory) + _name + ".config"; XConfigData conf = new XConfigData(); if (!_combined) { conf.SkillClip = AssetDatabase.GetAssetPath(_skillClip); conf.SkillClipName = _skillClip.name; } conf.Player = _id; conf.Directory = _directory; conf.SkillName = _name; XSkillData data = new XSkillData(); data.Name = _name; if (!_combined) { data.ClipName = conf.SkillClip.Remove(conf.SkillClip.LastIndexOf('.')); data.ClipName = data.ClipName.Remove(0, 17); } data.TypeToken = _combined ? 2 : 0; XDataIO <XSkillData> .singleton.SerializeData(skp, data); using (FileStream writer = new FileStream(config, FileMode.Create)) { XmlSerializer formatter = new XmlSerializer(typeof(XConfigData)); formatter.Serialize(writer, conf); } AssetDatabase.Refresh(); return(skp); }
public void ColdBuild(GameObject prefab, XConfigData conf) { if (hoster != null) { GameObject.DestroyImmediate(hoster); } hoster = UnityEngine.Object.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject; hoster.transform.localScale = Vector3.one * XTableMgr.GetTable <XEntityPresentation>().GetItemID((uint)conf.Player).Scale; hoster.AddComponent <XSkillHoster>(); hoster.GetComponent <CharacterController>().enabled = false; UnityEngine.AI.NavMeshAgent agent = hoster.GetComponent <UnityEngine.AI.NavMeshAgent>(); if (agent != null) { agent.enabled = false; } XSkillHoster component = hoster.GetComponent <XSkillHoster>(); string directory = conf.Directory[conf.Directory.Length - 1] == '/' ? conf.Directory.Substring(0, conf.Directory.Length - 1) : conf.Directory; string path = XEditorLibrary.GetPath("Skill" + "/" + directory); component.ConfigData = conf; component.SkillData = XDataIO <XSkillData> .singleton.DeserializeData(path + conf.SkillName + ".txt"); component.SkillDataExtra.ScriptPath = path; component.SkillDataExtra.ScriptFile = conf.SkillName; component.SkillDataExtra.SkillClip = RestoreClip(conf.SkillClip, conf.SkillClipName); if (component.SkillData.TypeToken != 2) { if (component.SkillData.Time == 0) { component.SkillData.Time = component.SkillDataExtra.SkillClip.length; } } HotBuildEx(component, conf); EditorGUIUtility.PingObject(hoster); Selection.activeObject = hoster; }