Author Topic: UICamera namespace not found  (Read 2983 times)

mathius777

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UICamera namespace not found
« on: August 05, 2012, 01:34:03 AM »
Hello. I am using the free version of NGUI right now. The GUI works in my game, however, I tried to create a UICamera in a script, and I get the error "The type or namespace name "UICamera" could not be found. Are you missing a using directive or an assembly reference. I can use NGUITools, but I can't use any UI reference in scripts. Any ideas? Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera namespace not found
« Reply #1 on: August 05, 2012, 09:06:11 AM »
Can you post the code you're using?

mathius777

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UICamera namespace not found
« Reply #2 on: August 05, 2012, 02:22:00 PM »
A script that someone posted on these forums.


using UnityEngine;


/// <summary>
/// Example script that instantiates a HUD window that will follow this game object.
/// </summary>

[AddComponentMenu("NGUI/Examples/Add Unit HUD")]
public class AddUnitHUD : MonoBehaviour
{
   public GameObject prefab;

   void Start ()
   {
      if (prefab != null)
      {
         UICamera cam = UICamera.FindCameraForLayer(prefab.layer);
      
         if (cam != null)
         {
            GameObject go = cam.gameObject;
            UIAnchor anchor = go.GetComponentInChildren<UIAnchor>();
            if (anchor != null) go = anchor.gameObject;

            GameObject child = GameObject.Instantiate(prefab) as GameObject;
            Transform t = child.transform;
            t.parent = go.transform;
            t.localPosition = Vector3.zero;
            t.localRotation = Quaternion.identity;
            t.localScale = Vector3.one;

            UnitHUD hud = child.GetComponent<UnitHUD>();
            if (hud != null) hud.target = transform;
         }
         else
         {
            Debug.LogWarning("No camera found for layer " + LayerMask.LayerToName(prefab.layer), gameObject);
         }
      }
      Destroy(this);
   }
}

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera namespace not found
« Reply #3 on: August 05, 2012, 04:06:21 PM »
Hmm... odd. I know it works with the full version though.

mathius777

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UICamera namespace not found
« Reply #4 on: August 06, 2012, 03:52:38 PM »
I see. I figured just including the NGUI folder would have been enough. Any suggestions?