• Register
1 vote
435 views

Problem :

Looking for the solution on bellow problem
setting the parent of a transform which resides in a prefab is disabled to prevent data corruption
6.9k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

You must confirm if your "transform" variable is actually from a gameobject and not from a prefab.

var transform = somePrefab.transform;
enemy.transform.parent = transform; // this will not work

var transform = someOtherGameObject.transform;
enemy.transform.parent = transform;
// this will work
38.6k points

Related questions

0 votes
1 answer 28 views
28 views
Problem: I want to create dynamically ui button, I have one prefab, here is code: public class SFSConnect : MonoBehaviour { SmartFox sfs; public GameObject cnv1; public GameObject potchPrf; public Canvas fCanvas; void Start () { fCanvas = cnv1.GetComponent<Canvas> ... 10), Quaternion.identity); potchPrf.transform.SetParent (fCanvas.transform); } } I tried thousands of posts, but nothing happened.
asked May 1 anika11 32.2k points
0 votes
1 answer 11 views
11 views
Problem: Can anyone simplify this : Setting the parent of a transform which resides in a prefab?
asked Jun 23 Chi Omega 168k points
0 votes
1 answer 8 views
8 views
Problem: I have no idea how to solve this, someone help : Unity setting the parent of a transform which resides in a prefab
asked Jun 21 Sawyer Parviz 168k points
0 votes
1 answer 3 views
3 views
Problem: Unable to instantiate prefab. prefab may be broken
asked Jul 4 Hridoy 19.2k points
0 votes
1 answer 42 views
42 views
Problem: Cannot modify transform.position because it is not a variable. What can I do now?
asked May 7 Irenka Kiri 85.5k points
0 votes
1 answer 19 views
19 views
Problem: Unity can not play a disabled audio source
asked Jul 16 Sawyer Parviz 168k points
0 votes
1 answer 191 views
191 views
Problem: Can someone help, How to fix &ldquo;Can't Play a Disabled Audio Source&rdquo;? Any help is appreciated :)
asked Mar 16 ummesalma 29.1k points
0 votes
1 answer 11 views
11 views
Problem: Is there a way to get around this : Failed to decompress data for the assetbundle?
asked May 27 Rada Gracelynn 104k points
0 votes
1 answer 3 views
3 views
Problem: Unity cannot modify the return value of because it is not a variable.
asked Jul 4 Rada Gracelynn 104k points
0 votes
1 answer 4 views
4 views
Problem: Where should I seek assistance with this problem : Unity operation is not valid due to the current state of the object?
asked Jun 18 Nahil 128k points