unity bug

不能申明变量

//----------------------------------------------
//            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

这个错误一直在啊

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值