Author Topic: Unity 5 AddChild Issue  (Read 4633 times)

Darkdevil79

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Unity 5 AddChild Issue
« on: March 11, 2015, 04:45:03 PM »
Hi all , I moved over to unity 5 and tried to use some of my code for a item to a gird , but I keep getting this error

Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.
UnityEngine.Transform:set_parent(Transform)
NGUITools:AddChild(GameObject, GameObject) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:511)

I had a look around but I could not find any info , so i thought I would let everyone know


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 5 AddChild Issue
« Reply #1 on: March 12, 2015, 08:23:17 PM »
You need to instantiate the game object before changing its hierarchy. You seem to be trying to change the parent of an object that exists as a prefab.

Darkdevil79

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Unity 5 AddChild Issue
« Reply #2 on: March 13, 2015, 01:16:02 PM »
Thank you for the reply , I found out the error , I got the object mixed up (it was a late night coding) :-[ , so it was trying to add root 100 times

Not one of my finest monents