Hey all,
After some frustrating realization, I found that I might not be screwing up serialization after all (ha).
But I have found that for some reason, my values are not getting assigned?
Let me demonstrate.
using UnityEngine;
using System.Collections;
using System; //Last 3 for Serialization
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
[System.Serializable]
public class GuardA : MonoBehaviour {
public StandardPlayerParadigm profile;
private Mercenary job;
private GuardPrototype type;
// Use this for initialization
public GuardA() { //I have also tried to use void Awake() and void Start() to no avail
profile = new StandardPlayerParadigm ();
job = new Mercenary ();
type = new GuardPrototype();
//decl the stats
profile.Name = "Guard A";
profile.stdType = type.stdType; //Which child of StandardType?
profile.Profession = job.Job; //Class
profile.ProfessionDescription = job.JobDescription; //ClassDescription
profile.Level = 1;
profile.Health = type.Health;
profile.Mana = type.Mana;
profile.TP = type.TP;
profile.Attack = type.Attack;
profile.Defense = type.Defense;
profile.MagicAttack = type.MagicAttack;
profile.MagicDefense = type.MagicDefense;
profile.Critical = type.Critical;
profile.Dexterity = type.Dexterity;
profile.HitRate = type.HitRate;
}
// Update is called once per frame
void Update () {
}
}
This code borrows from three other scripts, so let me break down their purpose before showing the code.
- StandardPlayerParadigm controls what a character SHOULD have at all times. I made StandardPlayerParadigm profile in GuardA so that I could load the values TO the comprehensive list of variables.
- Mercenary is a job that will eventually control weapons and armor choices but for now just has the name of the job (Mercenary) and the description of it so I can see it is working.
- Finally, the GuardPrototype has a list of actual values for the player stats, and as such, I want to assign those as well to the variables available through profile.
Now, I don't know that I could make this thread look good by including ALL of the code bits on the page, so here is my gist that I used previously in a different thread.
https://gist.github.com/alucard55/61df6f96fef4d9111ec98315a4f8a785None of the code is different in essence, and contains the full line of inheritance that the scripts borrow from etc and so forth until I want it to be used in GuardA.cs .
Now here's the TL;DR (sort of) for this.
When I have the part in GuardA where I say profile.Name = "Guard A"; etc and so forth to the end, none of these get assigned. However, I know the values are available, because if I make private Mercenary job/private GuardPrototype type into public variables, then I can see in Unity's inspector that the values are definitely there, I'm just not able to GET these values and put them in the variables I want, I guess.
So now TL;DR: Why is this not getting assigned? What do I need to do in order to do it, and is there anything I should know going forward about this sort of thing (as in, is it easy to mess up like I did, or did I just do a dumb)?