I am trying to load a prefab from a file and create a clone of the loaded file without instantiating it. Changing the data values of the loaded clones script, should then not change the prefabs values.
I am in a way trying to create a clone of a cloned and loaded prefab.
Loading a prefab into unity using Resources.Load:
enemy = new Player();
enemy.playerColor = Color.red;
enemy.Name = "enemy";
enemy.unitList.AddResources.Load("Prefab/Soldier", typeof(GameObject)) as GameObject);
Loading a prefab with the instantiate clone function:
enemy = new Player();
enemy.playerColor = Color.red;
enemy.Name = "enemy";
enemy.unitList.Add(Instantiate(Resources.Load("Prefab/Soldier", typeof(GameObject)) as GameObject) as GameObject);
Changing the loaded prefab:
public void updateUnit(string prop, float val)
{
switch (prop)
{
case "Movespeed":
Movespeed += (int)val;
break;
case "SpawnRate":
SpawnRate += val;
break;
}
}
The current problem is that using the instantiate function on the prefab, creates the clone on the screen. Whilst using the loaded prefab results in changes in the script in the prefab