浏览代码

Merge pull request #9 from UnityTechnologies/main

Pulled main changes
/AdsTesting
GitHub 4 年前
当前提交
6a8a1f48
共有 6 个文件被更改,包括 96 次插入16 次删除
  1. 3
      .gitignore
  2. 39
      Assets/Scenes/Level_00.unity
  3. 58
      Assets/Scripts/PlayerController.cs
  4. 1
      Packages/manifest.json
  5. 9
      Packages/packages-lock.json
  6. 2
      ProjectSettings/PackageManagerSettings.asset

3
.gitignore


# Visual Studio cache directory
.vs/
# Rider
.idea/
# Gradle cache directory
.gradle/

39
Assets/Scenes/Level_00.unity


m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 7702242263051669513, guid: 11482ef509975be43bcaf454f9771aed,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0.012939453
objectReference: {fileID: 0}
- target: {fileID: 7702242263277782300, guid: 11482ef509975be43bcaf454f9771aed,
type: 3}
propertyPath: m_AnchoredPosition.x
value: -2.6000366
objectReference: {fileID: 0}
- target: {fileID: 7702242263277782300, guid: 11482ef509975be43bcaf454f9771aed,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.30004883
objectReference: {fileID: 0}
- target: {fileID: 7702242264122354704, guid: 11482ef509975be43bcaf454f9771aed,
type: 3}
propertyPath: m_Pivot.x

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1357391161}
m_Mesh: {fileID: -5852286375780045605, guid: 380d56822eca0fb428c002e54147496a, type: 3}
--- !u!1 &1496090740 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2550463727306718371, guid: 380d56822eca0fb428c002e54147496a,
type: 3}
m_PrefabInstance: {fileID: 690134877}
m_PrefabAsset: {fileID: 0}
--- !u!65 &1496090744
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1496090740}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.10034926, y: 0.17949441, z: 0.0024161125}
m_Center: {x: 0.00082935765, y: -0.01894978, z: -0.0012080562}
--- !u!1 &1537944763
GameObject:
m_ObjectHideFlags: 0

propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 8083381679980500539, guid: 67db914bd437a69468c6d966454659b0,
type: 3}
propertyPath: m_MainCamera
value:
objectReference: {fileID: 949507758}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 67db914bd437a69468c6d966454659b0, type: 3}
--- !u!1001 &2096555481

58
Assets/Scripts/PlayerController.cs


private int m_VelocityHash = Animator.StringToHash("Velocity");
private Camera m_MainCamera;
private RaycastHit m_HitInfo;
const float k_MinMovementDistance = 1.2f;
m_MainCamera = Camera.main;
}
private void KeyCollected()

void Update()
{
float xMovement = m_MovementSpeed * Input.GetAxis("Horizontal");
float zMovement = m_MovementSpeed * Input.GetAxis("Vertical");
// TODO: Refactor this
if(xMovement < 0)
#if UNITY_EDITOR
if (Input.GetMouseButton(0))
m_Rigidbody.rotation = Quaternion.Euler(0, -90, 0);
MoveToPosition(Input.mousePosition);
else if(xMovement > 0)
else
m_Rigidbody.rotation = Quaternion.Euler(0, 90, 0);
m_Rigidbody.velocity = Vector3.zero;
else if(zMovement < 0)
#elif UNITY_IOS || UNITY_ANDROID
if (Input.touchCount > 0)
m_Rigidbody.rotation = Quaternion.Euler(0, 180, 0);
Touch touch = Input.GetTouch(0);
MoveToPosition(touch.position);
else if(zMovement > 0)
else
m_Rigidbody.rotation = Quaternion.Euler(0, 0, 0);
m_Rigidbody.velocity = Vector3.zero;
#endif
// apply aniamtion
m_AnimatorController.SetFloat(m_VelocityHash, m_Rigidbody.velocity.magnitude);
}
m_Rigidbody.velocity = new Vector3(xMovement, 0, zMovement);
void MoveToPosition(Vector2 screenPosition)
{
if (Physics.Raycast(m_MainCamera.ScreenPointToRay(screenPosition), out m_HitInfo))
{
// don't move if touching close to character
if (Vector3.Distance(m_Rigidbody.position, m_HitInfo.point) > k_MinMovementDistance)
{
// rotation
m_Rigidbody.transform.LookAt(m_HitInfo.point, Vector3.up);
// lock rotation to y
Vector3 eulerAngle = m_Rigidbody.transform.eulerAngles;
m_Rigidbody.transform.eulerAngles = new Vector3(0, eulerAngle.y, 0);
// We use the velocity of the character's rigidbody to drive the animation
m_AnimatorController.SetFloat(m_VelocityHash, m_Rigidbody.velocity.magnitude);
// calculate move direction vector
Vector3 movementDirection = m_HitInfo.point - m_Rigidbody.position;
movementDirection.Normalize();
// apply calculated velocity
m_Rigidbody.velocity = movementDirection * m_MovementSpeed;
}
}
}
}

1
Packages/manifest.json


"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.addressables": "1.16.16",
"com.unity.ide.rider": "1.1.4",
"com.unity.postprocessing": "3.0.1",
"com.unity.scriptablebuildpipeline": "1.16.1",
"com.unity.test-framework": "1.1.20",

9
Packages/packages-lock.json


"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "1.1.4",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
},
"url": "https://packages.unity.com"
},
"com.unity.postprocessing": {
"version": "3.0.1",
"depth": 0,

2
ProjectSettings/PackageManagerSettings.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
m_Script: {fileID: 13960, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_ScopedRegistriesSettingsExpanded: 1

正在加载...
取消
保存