база
This commit is contained in:
1 parent
6e3d5ab9a2
commit
c9085558cd
552 files changed
+133467
-220
No files matched your search
@@ -0,0 +1,85 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GunView : MonoBehaviour
|
||||
{
|
||||
Vector3 baseScale = new Vector3(0.7f, 0.7f, 0.7f);
|
||||
bool isPhone = false, isFirst = true;
|
||||
float zRot = 0, yRot = 0;
|
||||
Vector3 startPos;
|
||||
private void OnEnable()
|
||||
{
|
||||
transform.localScale = baseScale;
|
||||
if (SystemInfo.deviceType == DeviceType.Handheld)
|
||||
isPhone = true;
|
||||
isFirst = true;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if(isPhone)
|
||||
{
|
||||
if (Input.touchCount > 0)
|
||||
{
|
||||
if (isFirst)
|
||||
{
|
||||
isFirst = false;
|
||||
startPos = Input.GetTouch(0).position;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
zRot += (Input.GetTouch(0).position.y - startPos.y) * 0.09f;
|
||||
zRot = Mathf.Clamp(zRot, -55, 55);
|
||||
yRot += (Input.GetTouch(0).position.x - startPos.x) *0.25f;
|
||||
//yRot = Mathf.Clamp(yRot, -75, 75);
|
||||
startPos = Input.GetTouch(0).position;
|
||||
}
|
||||
ScaleUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
isFirst = true;
|
||||
zRot = Mathf.Lerp(zRot, 0, 0.08f);
|
||||
yRot = Mathf.Lerp(yRot, 0, 0.08f);
|
||||
ScaleDown();
|
||||
}
|
||||
transform.eulerAngles = new Vector3(0, 90 + yRot, zRot);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
if(isFirst)
|
||||
{
|
||||
isFirst = false;
|
||||
startPos = Input.mousePosition;
|
||||
return;
|
||||
}else
|
||||
{
|
||||
zRot += (Input.mousePosition.y - startPos.y) * 0.1f;
|
||||
zRot = Mathf.Clamp(zRot, -55, 55);
|
||||
yRot += (Input.mousePosition.x - startPos.x) * 0.3f;
|
||||
//yRot = Mathf.Clamp(yRot, -55, 55);
|
||||
startPos = Input.mousePosition;
|
||||
}
|
||||
ScaleUp();
|
||||
}else
|
||||
{
|
||||
isFirst = true;
|
||||
zRot = Mathf.Lerp(zRot, 0, 0.2f);
|
||||
yRot = Mathf.Lerp(yRot, 0, 0.2f);
|
||||
ScaleDown();
|
||||
}
|
||||
transform.eulerAngles = new Vector3(0,90 + yRot,zRot);
|
||||
}
|
||||
}
|
||||
void ScaleUp()
|
||||
{
|
||||
transform.localScale = Vector3.Lerp(transform.localScale, Vector3.one, 0.075f);
|
||||
}
|
||||
void ScaleDown()
|
||||
{
|
||||
transform.localScale = Vector3.Lerp(transform.localScale, baseScale, 0.075f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc74bb52495beed45aa2ab2ba4b460ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 192553
|
||||
packageName: 'Guns Pack: Low Poly Guns Collection'
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/Low Poly Guns/Scripts/GunView.cs
|
||||
uploadId: 430093
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class GunsMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject Buttons;
|
||||
public GameObject[] Guns;
|
||||
int currentGun = 0;
|
||||
void Start()
|
||||
{
|
||||
Guns[0].SetActive(true);
|
||||
}
|
||||
|
||||
public void NextGun()
|
||||
{
|
||||
Guns[currentGun ].SetActive(false);
|
||||
currentGun++;
|
||||
if (currentGun >= Guns.Length)
|
||||
currentGun = 0;
|
||||
Guns[currentGun].SetActive(true);
|
||||
}
|
||||
public void PreviousGun()
|
||||
{
|
||||
Guns[currentGun].SetActive(false);
|
||||
currentGun--;
|
||||
if (currentGun < 0)
|
||||
currentGun = Guns.Length - 1;
|
||||
Guns[currentGun].SetActive(true);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if ((Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)))
|
||||
{
|
||||
Buttons.SetActive(false);
|
||||
}
|
||||
else if(Input.touchCount == 0 && !Input.GetMouseButton(0))
|
||||
{
|
||||
Buttons.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c859d416b6fab4749b7d8f1d9dc840eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 192553
|
||||
packageName: 'Guns Pack: Low Poly Guns Collection'
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/Low Poly Guns/Scripts/GunsMenu.cs
|
||||
uploadId: 430093
|
||||
Reference in new issue
Block a user