private void DummySettings() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Dummy Id", _myLabelStyle); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); int idx = EditorGUILayout.IntField((int)Hoster.ConfigData.Dummy); Hoster.SkillDataExtra.Dummy = XEditorLibrary.GetDummy((uint)idx); Hoster.ConfigData.Dummy = idx; if (Hoster.SkillDataExtra.Dummy != null) { GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(Hoster.SkillDataExtra.Dummy.name, _myLabelStyle, new GUILayoutOption[] { GUILayout.MaxWidth(150) }); if (GUILayout.Button("add")) { GameObject hitter = UnityEngine.Object.Instantiate(Hoster.SkillDataExtra.Dummy, Hoster.transform.position, Quaternion.identity) as GameObject; hitter.AddComponent <XHitHoster>().PresentID = (int)Hoster.ConfigData.Dummy; Selection.activeGameObject = hitter; } } EditorGUILayout.EndHorizontal(); }
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); }
private void DeserializeData(string file) { _hoster.ConfigData = XDataIO <XConfigData> .singleton.DeserializeData(XEditorLibrary.GetCfgFromSkp(file)); _hoster.SkillData = XDataIO <XSkillData> .singleton.DeserializeData(file); XDataBuilder.singleton.HotBuildEx(_hoster, _hoster.ConfigData); }
public override void Flush() { _prefab = _data.bUsingID ? XEditorLibrary.GetStatics((uint)_data.StatisticsID) : Resources.Load(_data.Prefab) as GameObject; _clip = Resources.Load(_data.Clip, typeof(AnimationClip)) as AnimationClip; _using_id = _data.bUsingID; _id = _data.StatisticsID; _common = _data.bToCommonPool; _tag = _data.Tag; }
protected override void OnInnerGUI(XCutSceneData data) { _using_id = EditorGUILayout.Toggle("Using ID", _using_id); if (!_using_id) { _id = 0; _prefab = EditorGUILayout.ObjectField("Prefab", _prefab, typeof(GameObject), true) as GameObject; } else { _id = EditorGUILayout.IntField("Statistics ID", _id); _prefab = XEditorLibrary.GetStatics((uint)_id); if (_prefab != null) { EditorGUILayout.ObjectField("Prefab", _prefab, typeof(GameObject), true); } else { _id = 0; } } if (!XEditorLibrary.CheckPrefab(_prefab)) { _prefab = null; } if (_prefab != null) { _clip = EditorGUILayout.ObjectField("Animation", _clip, typeof(AnimationClip), true) as AnimationClip; Vector3 Appear = Vector3FieldEx("Appear At", new Vector3(_data.AppearX, _data.AppearY, _data.AppearZ), ref _appear_fold); _data.AppearX = Appear.x; _data.AppearY = Appear.y; _data.AppearZ = Appear.z; } if (_using_id) { EditorGUILayout.Space(); _common = EditorGUILayout.Toggle("Common", _common); _tag = EditorGUILayout.TextField("Tag", _tag); } }
public void Load(string pathwithname) { try { string path = XEditorLibrary.GetCfgFromSkp(pathwithname); XConfigData conf = XDataIO <XConfigData> .singleton.DeserializeData(path); GameObject prefab = XEditorLibrary.GetDummy((uint)conf.Player); if (prefab == null) { XDebug.LogError("Prefab not found by id: ", conf.Player); return; } ColdBuild(prefab, conf); prefixPath = pathwithname.Substring(0, pathwithname.IndexOf("/Skill")); Time = File.GetLastWriteTime(pathwithname); } catch (Exception e) { XDebug.LogError("Error occurred during loading config file: ", pathwithname, " with error:\n", e.StackTrace); } }
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; }
void OnGUI() { if (_labelstyle == null) { _labelstyle = new GUIStyle(EditorStyles.boldLabel); _labelstyle.fontSize = 13; } GUILayout.Label(@"Create and edit a new skill:", _labelstyle); _name = EditorGUILayout.TextField("*Skill Name:", _name); _directory = EditorGUILayout.TextField("*Directory:", _directory); if (_directory.Length > 0 && _directory[_directory.Length - 1] == '/') { _directory.Remove(_directory.Length - 1); } EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); _id = EditorGUILayout.IntField("*Dummy ID", _id); if (EditorGUI.EndChangeCheck()) { _prefab = XEditorLibrary.GetDummy((uint)_id); } EditorGUILayout.ObjectField("*Dummy Prefab:", _prefab, typeof(GameObject), true); AnimationClip skillClip = null; if (!_combined) { skillClip = EditorGUILayout.ObjectField("*Skill Animation:", _skillClip, typeof(AnimationClip), true) as AnimationClip; } _combined = EditorGUILayout.Toggle("Combined Skill", _combined); if (skillClip != null) { string location = AssetDatabase.GetAssetPath(skillClip); if (skillClip == null || location.IndexOf(".anim") != -1) { _skillClip = skillClip; } else { EditorUtility.DisplayDialog("Confirm your selection.", "Please select extracted skill clip!", "Ok"); } } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Done")) { if (_prefab != null && (_combined || _skillClip != null)) { Scene scene = EditorSceneManager.GetActiveScene(); if (scene.name.Length > 0 && !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { Close(); } else { EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); OnSkillPreGenerationDone(); return; } } else { EditorUtility.DisplayDialog("Confirm your selection.", "Please select prefab and skill clip!", "Ok"); } } else if (GUILayout.Button("Cancel")) { Close(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.Label("* means this section can not be empty.", EditorStyles.foldout); }
public void Update(XSkillHoster hoster) { string pathwithname = hoster.SkillDataExtra.ScriptPath + hoster.ConfigData.SkillName + ".txt"; DateTime time = File.GetLastWriteTime(pathwithname); if (Time == default(DateTime)) { Time = time; } if (time != Time) { Time = time; if (EditorUtility.DisplayDialog("WARNING!", "Skill has been Modified outside, Press 'OK' to reload file or 'Ignore' to maintain your change. (Make sure the '.config' file for skill script has been well synchronized)", "Ok", "Ignore")) { hoster.ConfigData = XDataIO <XConfigData> .singleton.DeserializeData(XEditorLibrary.GetCfgFromSkp(pathwithname)); hoster.SkillData = XDataIO <XSkillData> .singleton.DeserializeData(pathwithname); HotBuildEx(hoster, hoster.ConfigData); } } }
private void SerializeData(string file) { _hoster.SkillData.Name = _hoster.SkillDataExtra.ScriptFile; if (_hoster.SkillData.TypeToken != 2) { string path = AssetDatabase.GetAssetPath(_hoster.SkillDataExtra.SkillClip).Remove(0, 17); _hoster.SkillData.ClipName = path.Remove(path.LastIndexOf('.')); } else { _hoster.SkillData.ClipName = null; } if (_hoster.SkillData.TypeToken != 0) { _hoster.SkillData.Ja = null; } if (_hoster.SkillData.Result != null) { foreach (XResultData data in _hoster.SkillData.Result) { if (data.Warning) { if (_hoster.SkillData.Warning == null || data.Warning_Idx >= _hoster.SkillData.Warning.Count) { EditorUtility.DisplayDialog("Confirm your configuration.", "Please select right Warning Index!", "Ok"); return; } } } } if (_hoster.SkillData.Warning != null) { for (int idx = 0; idx < _hoster.SkillData.Warning.Count; idx++) { int i = 0; for (; i < _hoster.SkillData.Result.Count; i++) { if (_hoster.SkillData.Result[i].Warning && _hoster.SkillData.Result[i].Warning_Idx == idx) { break; } } if (i == _hoster.SkillData.Result.Count) { EditorUtility.DisplayDialog("Confirm your configuration.", "Please MATCH your Results' and Warnings' Index!", "Ok"); return; } } } if (!((_hoster.SkillData.Result == null && _hoster.SkillData.Hit == null) || _hoster.SkillData.Result.Count == _hoster.SkillData.Hit.Count)) { EditorUtility.DisplayDialog("Confirm your configuration.", "Result count is not match with Hit count!", "Ok"); return; } if (_hoster.SkillData.Hit != null) { int idx = 0; for (; idx < _hoster.SkillData.Hit.Count; idx++) { if (((_hoster.SkillData.Hit[idx].State == XBeHitState.Hit_Back || _hoster.SkillData.Hit[idx].State == XBeHitState.Hit_Roll) && (_hoster.SkillData.Hit[idx].Time_Present_Straight == 0 || _hoster.SkillData.Hit[idx].Time_Hard_Straight == 0 || _hoster.SkillData.Hit[idx].Offset == 0)) || (_hoster.SkillData.Hit[idx].Height == 0 && _hoster.SkillData.Hit[idx].State == XBeHitState.Hit_Fly) || (_hoster.SkillData.Hit[idx].FreezeDuration == 0 && _hoster.SkillData.Hit[idx].State == XBeHitState.Hit_Freezed)) { break; } } if (idx < _hoster.SkillData.Hit.Count) { EditorUtility.DisplayDialog("Confirm your configuration.", "your Hit parameters == 0!", "Ok"); return; } } StripData(_hoster.SkillData); XDataIO <XSkillData> .singleton.SerializeData(file, _hoster.SkillData); XDataIO <XConfigData> .singleton.SerializeData(XEditorLibrary.GetCfgFromSkp(file), _hoster.ConfigData); XDataBuilder.Time = File.GetLastWriteTime(file); }