The question is answered, right answer was accepted
unity 2018.3 prefab overwriting issue
hi! Im having issues with prefabs currently. Everytime I "edit" / change a instantiated prefab object it seems to overwrite / do the same changes to the prefab itself. How can I stop this? I know unpacking the prefab seems to work, but how would I do this in a script? I also keep getting this error when trying to parent an object
Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject: 'Inventory_ItemBox'). UnityEngine.Transform:set_parent(Transform)
First, you are doing this from a script or from the inspector?
IF you change the properties of a instantiated object, from the inspector, it will NOT change the prefab (unless you click on "apply".
IF you are doing it from script, can you post it please?
Bye!
Answer by sisuusis10 · Jan 24, 2019 at 05:20 PM
im doing this from script @tormentoarmagedoom,
using UnityEngine;
public class AxeHitBox : MonoBehaviour { public GameObject Hit; public AxeScript Axe;
private void OnTriggerEnter(Collider other) {
Axe.IsDamaging = false;
Instantiate(Hit);
Hit.transform.position = this.transform.position;
Hit.transform.rotation = this.transform.rotation;
Hit.transform.localScale = this.transform.localScale;
Hit.transform.parent = other.gameObject.transform;
}
}
tho i think I've know why. Im guessing its because its directly linked to the prefab itself on the "Hit" variable, there for it applys the scale change to the prefab itslef. tho its what im guessing atleast. tho im not sure how to work around this.
Follow this Question
Related Questions
Polybrush won't save to prefab 1 Answer
Making an endless hallway with random objects spawning 0 Answers
updating prefab without changing instances, no code 0 Answers
Changing rotation of prefab 0 Answers
Prefab with multiple meshes? 1 Answer