資源簡介
文章《Unity3D學習筆記07:射線Ray實現點擊拾取》的項目源碼

代碼片段和文件信息
using?UnityEngine;
using?System.Collections;
public?class?rayscript?:?MonoBehaviour?{
//?Use?this?for?initialization
void?Start?()?{
}
//?Update?is?called?once?per?frame
void?Update?()?{
????????//創建一條射線,產生的射線是在世界空間中,從相機的近裁剪面開始并穿過屏幕position(xy)像素坐標(position.z被忽略)
????????Ray?ray?=?camera.ScreenPointToRay(Input.mousePosition);
????????//RaycastHit是一個結構體對象,用來儲存射線返回的信息
????????RaycastHit?hit;
????????//如果射線碰撞到對象,把返回信息儲存到hit中
????????if?(Physics.Raycast(ray?out?hit))
????????{
????????????//如果碰撞的對象是小球,則銷毀它
????????????if?(hit.transform.gameobject.name?==?“Sphere“)
????????????{
????????????????Destroy(hit.transform.gameobject);
????????????}
????????}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2641??2013-08-24?20:53??RayTest\Assembly-CSharp-vs.csproj
?????文件???????2641??2013-08-24?20:53??RayTest\Assembly-CSharp.csproj
?????文件????????785??2013-08-24?21:53??RayTest\Assets\raysc
????I.A....?????20360??2013-08-24?22:00??RayTest\Assets\scene.unity
????I.A....??????4116??2013-08-24?20:43??RayTest\Library\AnnotationManager
????I.A....?????23528??2013-08-24?22:00??RayTest\Library\assetDataba
????I.A....?????????6??2013-08-24?20:43??RayTest\Library\AssetImportState
????I.A....??????5044??2013-08-24?22:00??RayTest\Library\AssetServerCacheV3
????I.A....?????????0??2013-08-24?20:43??RayTest\Library\BuildPla
????I.A....??????4116??2013-08-24?20:43??RayTest\Library\BuildSettings.asset
????I.A....??????4160??2013-08-24?20:43??RayTest\Library\EditorUserBuildSettings.asset
????I.A....??????4108??2013-08-24?20:43??RayTest\Library\EditorUserSettings.asset
????I.A....??????4124??2013-08-24?22:00??RayTest\Library\expandedItems
????I.A....?????????0??2013-08-24?22:00??RayTest\Library\FailedAssetImports.txt
????I.A....??????4184??2013-08-24?22:00??RayTest\Library\guidmapper
????I.A....??????4104??2013-08-24?20:43??RayTest\Library\InspectorExpandedItems.asset
????I.A....??????4268??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4304??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4296??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4308??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4308??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4296??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4304??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4304??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4308??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4308??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4308??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4320??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4308??2013-08-24?20:43??RayTest\Library\me
????I.A....??????4284??2013-08-24?22:00??RayTest\Library\me
............此處省略290個文件信息
評論
共有 條評論