• Register
1 vote
220 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

1 vote
2 answers 86 views
86 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
0 votes
1 answer 245 views
245 views
Problem : I am very new to C#. I have written the below C# code. void UpdateAxis () { float myxP = Input.GetAxis ("Horizontal")*Time.deltaTime * 20; transform.Translate (Vector3(myxP,0,0));//error is here transform.position.x = Mathf.Clamp (transform. ... the above code. error : Expression denotes a type', where avariable', value' ormethod group' was expected` Kindly suggest the solution if any.
asked Dec 3, 2019 alecxe 7.5k points
0 votes
2 answers 560 views
560 views
Problem : I am new to Unity5. I am facing following error while trying to do setDestination. "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3) CompleteProject.EnemyMovement:Update() (at Assets/ ... ; } } } } May I know what is wrong with the above code? Does anyone have any solution on my issue?
asked Nov 27, 2019 alecxe 7.5k points
1 vote
3 answers 1.6K views
1.6K views
Problem : I am very new to unity. Recently I had updated my unity from the earlier unity5 to the current 2018.2.2f1. And after that update my Unity scripts are not at all loading. I had also tried to play my Scene but my scripts are not at all loading and I am ... time on fixing above error but still unable to fix it so looking for the expert help who can help me in fixing my issue in less time.
asked Apr 10, 2020 morrisBson 3.2k points
0 votes
1 answer 413 views
413 views
Problem : I am trying to create the test app using unity but facing following issue: readpixels was called to read pixels from system frame buffer, while not inside drawing frame.
asked Nov 14, 2019 peterlaw 6.9k points
0 votes
1 answer 111 views
111 views
Problem : I am getting bellow error related to datetime the conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
1 answer 2.3K views
2.3K views
Problem : How can i fix the following error build completed with a result of 'failed' unityengine.guiutility:processevent(int32, intptr)
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
1 answer 18 views
18 views
Problem: Hi there! I am new to the world of programming and learning loop constructs in C#. My concept for loops is clear but I just recently encountered a code somewhere in which for loop was initialized as follows: for(;;) { } I tried running that code, but it ... I make some mistake but I want to know more about ‘for’ loops and all the possible ways in which it can be used. Thanks!
asked Nov 27, 2020 Code Learner 5.5k points
0 votes
1 answer 20 views
20 views
Problem: Hi there! I am newbie and I am want to strip away specific characters from the end of a string. I am programming in C#. I have tried Remove() method as follows: using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { ... the index of string myself. I want to know that is there any way in C# to remove characters from strings without specifying the index?
asked Nov 27, 2020 Code Learner 5.5k points
0 votes
1 answer 44 views