Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Parent Object is null

Discussion in 'Scripting' started by jillmitchell100, Jun 18, 2017.

  1. jillmitchell100

    jillmitchell100

    Joined:
    Mar 1, 2014
    Posts:
    8
    Delete this tread. A simple test and everything worked. but in my game can't see the parent, it is null in the hierarchy. 3 hours hackin at this, maybe some sleep will help.
     
    Last edited: Jun 19, 2017
  2. Rick-Gamez

    Rick-Gamez

    Joined:
    Mar 23, 2015
    Posts:
    218
    The way you have it should work... And the parent shouldn't be null... Let me see if I can't replicate the problem.
     
  3. Rick-Gamez

    Rick-Gamez

    Joined:
    Mar 23, 2015
    Posts:
    218
    Yea Im having some strange issues there too. Let me see if I can't now come up with a solution

    [A few Minutes Later]
    Wow this is really weird give me some time cause ima have to get creative on this one. But this seems to be a unity bug not a problem with your code
     
    Last edited: Jun 19, 2017
  4. Rick-Gamez

    Rick-Gamez

    Joined:
    Mar 23, 2015
    Posts:
    218
    Okay this is quick and dirty but it works for me.
    Code (csharp):
    1.  
    2. void Start(){
    3.     var all = Object.FindObjectsOfType<Transform> ();
    4.         foreach (var i in all) {
    5.             if (i == transform) {
    6.                 Debug.Log (i.parent);
    7.                 break;
    8.             }
    9.         }
    10.     }
    11.  
    It seems to be an issue with GameObject / Transform variable assignment in the inspector but if you get the transforms via the start method (or whatever method) then it seems to get me past the problem just fine... Ill see about reporting this bug so that it's not a problem in the future. Thanks for bringing this to our attention
     
    Last edited: Jun 19, 2017