Author Topic: Cannot create a prefab with UIFollow target? (Camera value is not set.)  (Read 1235 times)

kobald

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
I think I understand some behavior I am seeing, but just wanted to clarify with more experienced Unity devs.

I'm trying to create a prefab with a UIFollowTarget component. The UIFollowTarget is set up correctly (with the `camera` and `uiCamera` fields set). However, when I create a Prefab instance out of my GameObject, the camera fields are no longer set. Instead, for the prefab they go back to a None value.

Am I correct in assuming that a prefab object cannot contain references to things not in the prefab's hierarchy? That is, a prefab can contain a reference to a child/descendent object. But a prefab cannot contain a reference to a parent/sibling object?

If so, that would explain this behavior. Since the UI and game cameras are not in the UIFollowTarget's object hierarchy.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cannot create a prefab with UIFollow target? (Camera value is not set.)
« Reply #1 on: February 13, 2014, 12:24:34 AM »
That's right -- you can't reference scripts that are not a part of the same prefab. Prefabs exist in "limbo", and know nothing about your scene objects. That's how Unity works.