資源簡介
用unity+高德地理定位做的,模仿pokemon go的嘗試的demo。
源碼太大,所以分成兩部分。
詳細內容看http://blog.csdn.net/wuyt2008/article/details/52934083
代碼片段和文件信息
using?UnityEngine;
using?System.Collections;
namespace?TAK_CameraController
{
enum?MouseButtonDown
{
MBD_LEFT?=?0
MBD_RIGHT
MBD_MIDDLE
};
public?class?CameraController?:?MonoBehaviour
{
[SerializeField]
private?Vector3?focus?=?Vector3.up;
[SerializeField]
private?Gameobject?focusObj?=?null;
private?Vector3?oldPos;
void?setupFocusobject(string?name)
{
Gameobject?obj?=?this.focusObj?=?new?Gameobject(name);
obj.transform.position?=?this.focus;
obj.transform.LookAt(this.transform.position);
return;
}
void?Start?()
{
if?(this.focusObj?==?null)
this.setupFocusobject(“CameraFocusobject“);
Transform?trans?=?this.transform;
transform.parent?=?this.focusObj.transform;
trans.LookAt(this.focus?+?new?Vector3(0?1?1));
return;
}
void?Update?()
{
this.mouseEvent();
return;
}
void?mouseEvent()
{
float?delta?=?Input.GetAxis(“Mouse?ScrollWheel“);
if?(delta?!=?0.0f)
this.mouseWheelEvent(delta);
if?(Input.GetMouseButtonDown((int)MouseButtonDown.MBD_LEFT)?||
????Input.GetMouseButtonDown((int)MouseButtonDown.MBD_MIDDLE)?||
????Input.GetMouseButtonDown((int)MouseButtonDown.MBD_RIGHT))
this.oldPos?=?Input.mousePosition;
this.mouseDragEvent(Input.mousePosition);
return;
}
void?mouseDragEvent(Vector3?mousePos)
{
Vector3?diff?=?mousePos?-?oldPos;
if?(Input.GetMouseButton((int)MouseButtonDown.MBD_LEFT))
{
if?(diff.magnitude?>?Vector3.kEpsilon)
this.cameraTranslate(-diff?/?100.0f);
}else?if?(Input.GetMouseButton((int)MouseButtonDown.MBD_MIDDLE))
{
if?(diff.magnitude?>?Vector3.kEpsilon)
this.cameraRotate(new?Vector3(diff.y?diff.x?0.0f));
}else?if?(Input.GetMouseButton((int)MouseButtonDown.MBD_RIGHT))
{
}
this.oldPos?=?mousePos;
return;
}
public?void?mouseWheelEvent(float?delta)
{
Vector3?focusToPosition?=?this.transform.position?-?this.focus;
Vector3?post?=?focusToPosition?*?(1.0f?+?delta);
if?(post.magnitude?>?0.01)
this.transform.position?=?this.focus?+?post;
return;
}
void?cameraTranslate(Vector3?vec)
{
Transform?focusTrans?=?this.focusObj.transform;
vec.x?*=?-1;
focusTrans.Translate(Vector3.right?*?vec.x);
focusTrans.Translate(Vector3.up?*?vec.y);
this.focus?=?focusTrans.position;
return;
}
public?void?cameraRotate(Vector3?eulerAngle)
{
Transform?focusTrans?=?this.focusObj.transform;
focusTrans.localEulerAngles?=?focusTrans.localEulerAngles?+?eulerAngle;
this.transform.LookAt(this.focus+?new?Vector3(0?1?0));
return;
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????I.A....????815840??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM03_0019_HeadSpring.fbx
????I.A....?????41347??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM03_0019_HeadSpring.fbx.me
????I.A....????832896??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM05_0000_Idle.fbx
????I.A....?????41303??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM05_0000_Idle.fbx.me
????I.A....????749312??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM05_0001_M_CMN_LJAB.fbx
????I.A....?????41301??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM05_0001_M_CMN_LJAB.fbx.me
????I.A....????863360??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM05_0022_M_RISING_P.fbx
????I.A....?????41311??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM05_0022_M_RISING_P.fbx.me
????I.A....????761616??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM_0012b_EH_RUN_LP_NoZ.fbx
????I.A....?????43376??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM_0012b_EH_RUN_LP_NoZ.fbx.me
????I.A....????796832??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM_04_0001_RHiKick.fbx
????I.A....?????41339??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM_04_0001_RHiKick.fbx.me
????I.A....????815840??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM_04_0010_MC2_SAMK.fbx
????I.A....?????41335??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\FUCM_04_0010_MC2_SAMK.fbx.me
????I.A....??????3231??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body.mat.me
????I.A....??????3232??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body1.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body1.mat.me
????I.A....??????3232??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body2.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body2.mat.me
????I.A....??????3232??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body3.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body3.mat.me
????I.A....??????3232??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body4.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body4.mat.me
????I.A....??????3232??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body5.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body5.mat.me
????I.A....??????3232??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body6.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body6.mat.me
????I.A....??????3232??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body7.mat
????I.A....???????181??2016-10-26?13:30??pokemon\Assets\FightingUnityChan_FreeAsset\FightingUnityChan_FreeAsset\Animations\Materials\body7.mat.me
............此處省略2971個文件信息
評論
共有 條評論