不能申明变量
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2014 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
[AddComponentMenu("NGUI/Examples/Drag and Drop Item (Example)")]
public class ExampleDragDropItem : UIDragDropItem
{
/// <summary>
/// Prefab object that will be instantiated on the DragDropSurface if it receives the OnDrop event.
/// </summary>
public GameObject prefab;
private bool creatTrankeSuccess=false;
/// <summary>
/// Drop a 3D game object onto the surface.
/// </summary>
protected override void OnDragDropRelease (GameObject surface)
{
Debug.Log ("surface name is+" + surface.name);
if (surface != null)
{
ExampleDragDropSurface dds = surface.GetComponent<ExampleDragDropSurface>();
//Debug.Log("ke yi yong le");
if (dds != null)
{
//Debug.Log("dds is not null");
int z_pos=(int)UICamera.lastWorldPosition.z;
z_pos=(z_pos-35)/5;
if(z_pos>6||z_pos<0){
base.OnDragDropRelease(surface);
return;
}
TankeCache[] tmp=dds.M_tanke;
if(null==dds.M_tanke[z_pos].Tanke){
GameObject child=GameObject.Instantiate(prefab)as GameObject;
dds.M_tanke[z_pos].Tanke=child;
child.transform.position=dds.M_tanke[z_pos].TankePos;
creatTrankeSuccess=true;
}
//Transform trans = child.transform;
//trans.position = UICamera.lastWorldPosition;
if (dds.rotatePlacedObject)
{
//trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f);
}
// Destroy this icon as it's no longer needed
//
}
//如果碰到了坦克
}
base.OnDragDropRelease(surface);
if(creatTrankeSuccess){
gameObject.transform.localPosition=new Vector3(-150,-3000,0);
NGUITools.SetActive(gameObject,false);
}
}//OnDragDropRelease end
void rayCollider(){
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);//从摄像机发出到点击坐标的射线
RaycastHit hitInfo;
if(Physics.Raycast(ray,out hitInfo))
{
Debug.DrawLine(ray.origin,hitInfo.point);//划出射线,只有在scene视图中才能看到
Vector3 weizhi=hitInfo.point;
Debug.Log(weizhi);
GameObject child=GameObject.Instantiate(prefab)as GameObject;
child.transform.position=hitInfo.point;
//GameObject gameObj = hitInfo.collider.gameObject;
//Debug.Log("click object name is " + gameObj.name);
}
}
}//class end
Assets/NGUI/Examples/Scripts/Other/ExampleDragDropItem.cs(75,35): error CS0103: The name `weizhi' does not exist in the current context
这个错误一直在啊