• Register
1 vote
319 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 5 3
6,930 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
9 7 4
38,600 points

Related questions

0 votes
1 answer 15 views
15 views
Problem: Can someone help, How to fix “Can't Play a Disabled Audio Source”? Any help is appreciated :)
asked Mar 16 ummesalma 21.4k points
0 votes
1 answer 1 view
1 view
Problem: I keep getting this error message:
asked Mar 16 ummesalma 21.4k points
0 votes
1 answer 8 views
8 views
Problem: I'm preloading a new scene using SceneManager.LoadSceneAsync to create an animation exit effect, but this gives me the error: There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene. Thanks for your help
asked Mar 19 ummesalma 21.4k points
0 votes
1 answer 18 views
18 views
Problem: Hello everyone I've been working on my first game and suddenly I got this error and cannot run the game: Unity3d no Monobehaviour scripts in the file or their names don't match the file name
asked Mar 16 ummesalma 21.4k points
0 votes
1 answer 6 views
6 views
Problem: I'm preloading a new scene using SceneManager.LoadSceneAsync to create an animation exit effect, but this gives me the error: There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene. Thanks for your help
asked Mar 16 ummesalma 21.4k points
0 votes
1 answer 38 views
38 views
Problem error building player because scripts have compile errors in the editor
asked Feb 11 charles mathews 5.5k points
0 votes
1 answer 3 views
3 views
Problem: I need someone’s help to fix it .. 7 days to die failed to read past end of stream
asked Apr 3 Ifra 24.4k points
0 votes
1 answer 5 views
5 views
Problem: Why I am getting this error: Object reference not set to an instance of an object - Instantiate Thanks
asked Mar 16 ummesalma 21.4k points
0 votes
1 answer 9 views
9 views
Problem: I am creating an editor script for a certain type of component script, I'd like to access the specific component script referenced by that instance of the editor script.
asked Mar 16 ummesalma 21.4k points
1 vote
2 answers 123 views
123 views
Problem: I am beginner to C# with Unity engine. I have already started learning C# with Unity engine. I have tried to write the very basic script as shown below for your reference: using UnityEngine; using System.Collections; public class scriptMyBall : MonoBehaviour { / ... but unable to fix the Unity Engine related error. I need Unity Engine’s expert who can guide me in fixing above error.
asked May 23, 2020 Martin K 6.6k points