add
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
//--------------------------------------------
|
||||
// NGUI: HUD Text
|
||||
// Copyright © 2012 Tasharen Entertainment
|
||||
//--------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("NGUI/Examples/HUD Root")]
|
||||
public class HUDRoot : MonoBehaviour
|
||||
{
|
||||
static public GameObject go;
|
||||
void Awake () { go = gameObject; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4e5389dad3931049b99d0d749bba30f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class HUDTest : UIEventListener {
|
||||
|
||||
public Transform hudAnchor;
|
||||
public Camera mGameCamera;
|
||||
public Camera mUICamera;
|
||||
public HUDText prefHudtxt;
|
||||
|
||||
HUDText hudtxt;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
if(hudtxt == null) {
|
||||
hudtxt = Object.Instantiate(prefHudtxt) as HUDText;
|
||||
hudtxt.transform.parent = HUDRoot.go.transform;
|
||||
hudtxt.transform.localScale = Vector3.one;
|
||||
hudtxt.transform.localPosition = Vector3.zero;
|
||||
UIFollowTarget ft = hudtxt.gameObject.AddComponent<UIFollowTarget>();
|
||||
ft.target = hudAnchor;
|
||||
ft.setCamera(mGameCamera, mUICamera);
|
||||
hudtxt.Add("Please click the cube...", Color.white, -1); //最后一个参数:-1 表示常驻
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OnClick() {
|
||||
if(hudtxt == null) {
|
||||
Start ();
|
||||
}
|
||||
hudtxt.Add(1, Color.red, 1);
|
||||
}
|
||||
|
||||
void OnDrag(Vector2 delta) {
|
||||
Vector3 off = new Vector3(delta.x, delta.y, 0);
|
||||
transform.localPosition += (off*0.01f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 551340f79aac243a88edd74355725dfa
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Reference in New Issue
Block a user