isaac
New Member
Posts: 1
|
Post by isaac on Jan 26, 2018 5:01:39 GMT
Hey there, as per your suggestion I created this thread to discuss in a bit more detail the issues I am having with game object data being set to null when exiting play and when loading up the project. A little background first. I am wanting to go away from a job system like FFTA and am trying to create a skill system. Rather than create a tree type class I had the idea to create a skill class that holds relevant data about the skill. Information like skill name, description, cost, tier, and ID are stored within the skill class. This skill is then loaded into a skill tree class that consists of a private list with the necessary setter to add to the list. I followed your example of the job parser tutorial to create a skill parser that creates a skill tree object. After the skill tree object is created data from a .csv file is read in. A skill object is created or updated. This skill object is then added to the skill tree. The Skill tree and skill objects can be viewed in the editor Attached is the relevant code; Skill Tree Proj.zip (2.69 KB) Let me know if you see any issues or have any suggestions. Thanks again!
|
|
|
Post by Admin on Jan 26, 2018 15:30:00 GMT
I have to admit, I am stumped as to why it is working for my job code and not working for your skill tree code. It must be some really obscure bug in Unity. However, I did manage to find a workaround that allows your objects to survive play mode and different sessions of Unity. I did so by marking the the prefab objects as "Dirty".
static void ParseSkillTree() { string readPath = string.Format("{0}/UnitSettings/NRG_MAGE_SkillTree.csv", Application.dataPath); string[] readText = File.ReadAllLines(readPath); GameObject obj = GetOrCreate("NRGMageSkills"); SkillTree NRGMageSkill = obj.GetComponent<SkillTree>(); //obj.GetComponent<SkillTree>; for (int i = 1; i < readText.Length; ++i) { var skill = PartsStartingStats (readText [i]); EditorUtility.SetDirty (skill.gameObject); NRGMageSkill.AddToList (skill); } EditorUtility.SetDirty (obj); }
|
|