提交农家乐
This commit is contained in:
parent
06a144fb6a
commit
39b6b419ab
|
@ -27,7 +27,7 @@ public static class AsyncWebReq
|
||||||
public static void SetValue(string jsonStr, out JObject _jbsx, out JObject _jsxx, out List<JObject> _jlzzxx)
|
public static void SetValue(string jsonStr, out JObject _jbsx, out JObject _jsxx, out List<JObject> _jlzzxx)
|
||||||
{
|
{
|
||||||
var json = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonStr);
|
var json = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonStr);
|
||||||
var data = json["data"] as JObject;
|
var data = json["datas"] as JObject;
|
||||||
|
|
||||||
var jbsxArr = data["jbsx"] as JArray;
|
var jbsxArr = data["jbsx"] as JArray;
|
||||||
var jbsx = jbsxArr[0] as JObject;
|
var jbsx = jbsxArr[0] as JObject;
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class LoginController : MonoBehaviour
|
||||||
//Debug.Log(msg.state);
|
//Debug.Log(msg.state);
|
||||||
//if (msg.state == "Fail")
|
//if (msg.state == "Fail")
|
||||||
//{
|
//{
|
||||||
// StartCoroutine(WaitCloseErrorPlane(msg.data[0].msg));
|
// StartCoroutine(WaitCloseErrorPlane(msg.datas[0].msg));
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
SwitchPanel(1);
|
SwitchPanel(1);
|
||||||
|
|
|
@ -16,7 +16,7 @@ using UnityEngine.UI;
|
||||||
|
|
||||||
public class FirstPersonController : MonoBehaviour
|
public class FirstPersonController : MonoBehaviour
|
||||||
{
|
{
|
||||||
private Rigidbody rb;
|
public Rigidbody rb;
|
||||||
|
|
||||||
#region Camera Movement Variables
|
#region Camera Movement Variables
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ public class FirstPersonController : MonoBehaviour
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
rb = GetComponent<Rigidbody>();
|
rb =GetComponent<Rigidbody>();
|
||||||
|
|
||||||
crosshairObject = GetComponentInChildren<Image>(true);
|
crosshairObject = GetComponentInChildren<Image>(true);
|
||||||
|
|
||||||
|
@ -369,12 +369,12 @@ public class FirstPersonController : MonoBehaviour
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
CheckGround();
|
CheckGround();
|
||||||
|
|
||||||
fieldView = playerCamera.fieldOfView;
|
fieldView = playerCamera.fieldOfView;
|
||||||
fieldView -= Input.GetAxis("Mouse ScrollWheel") * 10f;
|
fieldView -= Input.GetAxis("Mouse ScrollWheel") * 10f;
|
||||||
fieldView = Mathf.Clamp(fieldView, 20, 60);
|
fieldView = Mathf.Clamp(fieldView, 20, 60);
|
||||||
playerCamera.fieldOfView = fieldView;
|
playerCamera.fieldOfView = fieldView;
|
||||||
|
|
||||||
|
|
||||||
if (enableHeadBob)
|
if (enableHeadBob)
|
||||||
{
|
{
|
||||||
HeadBob();
|
HeadBob();
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!1 &2943890895030514617
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 2943890895030514615}
|
|
||||||
- component: {fileID: 2943890894315625057}
|
|
||||||
- component: {fileID: 2943890894315625058}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: GameManager
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &2943890895030514615
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2943890895030514617}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 28.539894, y: 1.8100001, z: 337.26544}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &2943890894315625057
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2943890895030514617}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: d38da66309ccf6640acd6bd3ea8ee27a, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!114 &2943890894315625058
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2943890895030514617}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: e0691636af8b1214b841d5b6bbad0f4f, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
content: {fileID: 0}
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &2943890895030514617
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2943890895030514615}
|
||||||
|
- component: {fileID: 2943890894315625056}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &2943890895030514615
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2943890895030514617}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 28.539894, y: 1.8100001, z: 337.26544}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &2943890894315625056
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2943890895030514617}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: b76f2fea1e26daf47800ae5368778726, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
"\u6545\u969C\u8BB0\u5F55\u8868": {fileID: 0}
|
||||||
|
"\u8BBE\u5907": {fileID: 0}
|
||||||
|
"\u8BE6\u7EC6\u7F3A\u9677": {fileID: 0}
|
||||||
|
"\u7F3A\u9677\u7C7B\u578B": {fileID: 0}
|
||||||
|
content: {fileID: 0}
|
||||||
|
"\u914D\u7535\u7BB1":
|
||||||
|
- "\u65E0\u5149\u4F0F\u63A5\u5165\u70B9\u6807\u5FD7"
|
||||||
|
- "\u4F4E\u538B\u5206\u754C\u5F00\u5173\u5F02\u5E38"
|
||||||
|
- "\u8FDB\u51FA\u7EBF\u642D\u63A5\u65E0\u94DC\u7247"
|
||||||
|
- "\u8FDB\u51FA\u7EBF\u642D\u63A5\u7EBF\u7F06\u8FDE\u63A5\u5F02\u5E38"
|
||||||
|
"\u7535\u7EBF\u6746":
|
||||||
|
- "\u65E0\u6746\u53F7"
|
||||||
|
- "\u65E0\u5206\u754C\u70B9\u7F16\u53F7 "
|
||||||
|
"\u5E76\u7F51\u67DC":
|
||||||
|
- "\u8B66\u793A\u6807\u5FD7\u4E0D\u9F50"
|
||||||
|
- "\u67DC\u4F53\u65E0\u63A5\u5730"
|
||||||
|
- "\u67DC\u95E8\u65E0\u63A5\u5730"
|
||||||
|
- "\u901A\u9053\u5185\u90E8\u6709\u6742\u7269"
|
||||||
|
- "\u51FA\u7EBF\u7F16\u53F7\u724C\u7F3A\u5931"
|
||||||
|
- "\u5E76\u7F51\u65AD\u8DEF\u5668\u7684\u5BB9\u91CF\u4E0E\u5BA2\u6237\u7533\u8BF7\u5BB9\u91CF\u4E0D\u76F8\u7B26"
|
||||||
|
- "\u9694\u79BB\u5F00\u5173\u7684\u5BB9\u91CF\u4E0E\u5BA2\u6237\u7533\u8BF7\u5BB9\u91CF\u4E0D\u76F8\u7B26"
|
||||||
|
- "\u5B9E\u65F6\u663E\u793A\u6700\u5927\u7535\u6D41\u6216\u529F\u7387\u8D85\u8FC7\u5907\u6848\u5BB9\u91CF"
|
||||||
|
"\u5E76\u7F51\u8BBE\u5907":
|
||||||
|
- "\u9006\u53D8\u5668\u5408\u8BA1\u5BB9\u91CF\u4E0E\u7528\u6237\u6863\u6848\u4E0D\u4E00\u81F4"
|
||||||
|
- "\u9006\u53D8\u5668\u5916\u58F3\u672A\u63A5\u5730"
|
||||||
|
- "\u9006\u53D8\u5668\u5B58\u5728\u6545\u969C\u62A5\u8B66\u73B0\u8C61"
|
||||||
|
- "\u6C47\u6D41\u7BB1\u5404\u79CD\u51FA\u7EBF\u5F00\u5173\u7684\u63A5\u7EBF\u7EBF\u7F06\u9732\u94DC"
|
||||||
|
- "\u67DC\u4F53\u5C01\u5835\u4E0D\u5B8C\u5584"
|
||||||
|
"\u8BA1\u91CF\u67DC":
|
||||||
|
- "\u8BA1\u91CF\u67DC\u524D\u540E\u95E8\u5C01\u5370\u4E0D\u5B8C\u6574"
|
||||||
|
- "\u67DC\u4F53\u524D\u540E\u95E8\u672A\u5173\u95ED"
|
||||||
|
- "\u8054\u5408\u63A5\u7EBF\u76D2\u5C01\u5370\u4E0D\u9F50\u5168"
|
||||||
|
- "\u8868\u8BA1\u5C01\u5370\u4E0D\u9F50\u5168"
|
||||||
|
- "\u4E92\u611F\u5668\u5C01\u5370\u4E0D\u9F50\u5168"
|
||||||
|
- "\u4E8C\u6B21\u56DE\u8DEF\u5BFC\u7EBF\u4E0D\u89C4\u8303"
|
||||||
|
- "\u4E92\u611F\u5668\u6709\u660E\u663E\u7684\u635F\u574F\u3001\u65AD\u88C2\u3001\u53D8\u5F62\u6216\u8131\u843D"
|
||||||
|
- "\u8868\u8BA1\u51FA\u7EBF\u5230\u8054\u5408\u63A5\u7EBF\u76D2\u4E4B\u95F4\u7EBF\u7F06\u9732\u94DC"
|
||||||
|
- "\u8054\u5408\u63A5\u7EBF\u76D2\u81F3\u4E92\u611F\u5668\u4E4B\u95F4\u7684\u63A5\u7EBF\u7EBF\u7F06\u9732\u94DC"
|
||||||
|
- "\u8868\u8BA1\u7535\u538B\u6709\u65AD\u76F8\u73B0\u8C61"
|
Before Width: | Height: | Size: 602 KiB After Width: | Height: | Size: 602 KiB |
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6f2f2317e83ddf642b3f96db49847598
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,162 @@
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
public class CameraControl : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static CameraControl Instance { private set; get; }
|
||||||
|
public float minDis = 0.5f;
|
||||||
|
public float maxDis = 1.5f;
|
||||||
|
public float rSmoothTime = 0.3f, sSmoothTime = 0.3f, mSmoothTime = 0.3f;
|
||||||
|
public float mouseRotSpeed = 8, mouseMoveSpeed = 1, mouseZoomSpeed = 15;
|
||||||
|
public float minVerticalAngle = -30, maxVerticalAngle = 60;
|
||||||
|
public float minHorizontalAngle = -60, maxHorizontalAngle = 60;
|
||||||
|
[Header("初始化数据"), SerializeField] float orginDis = 0;
|
||||||
|
Vector3 currentPosition, movVelocity, targetPosition;
|
||||||
|
float targetDis, currentDis, disVelocity;
|
||||||
|
Vector3 currentRotation, targetRotation, rotVelocity;
|
||||||
|
[SerializeField] Transform target;
|
||||||
|
Vector3 pos;
|
||||||
|
bool isok = false;
|
||||||
|
public bool ZhoLI = false;//是否是重力模式
|
||||||
|
float speed = 20;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
SetCameraTrans();
|
||||||
|
//Debug.Log("CameraControl");
|
||||||
|
}
|
||||||
|
[ContextMenu("设置相机位置")]
|
||||||
|
private void SetCameraTrans()
|
||||||
|
{
|
||||||
|
currentDis = targetDis = orginDis;
|
||||||
|
currentPosition = targetPosition = transform.position;
|
||||||
|
currentRotation = targetRotation = transform.localEulerAngles;
|
||||||
|
}
|
||||||
|
public void SetOrginDis(Vector3 orginPos, Vector3 orginRO)
|
||||||
|
{
|
||||||
|
target = null;
|
||||||
|
targetPosition = orginPos;
|
||||||
|
targetRotation = orginRO;
|
||||||
|
targetDis = 0;
|
||||||
|
}
|
||||||
|
public void SetPos(Vector3 pos,Vector3 ro)
|
||||||
|
{
|
||||||
|
targetPosition = pos;
|
||||||
|
targetRotation = ro;
|
||||||
|
}
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (Input.touchCount == 0 && Input.GetMouseButton(1))
|
||||||
|
{
|
||||||
|
targetRotation.y += Input.GetAxis("Mouse X") * mouseRotSpeed;
|
||||||
|
targetRotation.x -= Input.GetAxis("Mouse Y") * mouseRotSpeed;
|
||||||
|
}
|
||||||
|
targetDis = targetDis - Input.GetAxis("Mouse ScrollWheel") * mouseZoomSpeed;
|
||||||
|
targetRotation.x = Mathf.Clamp(targetRotation.x, minVerticalAngle, maxVerticalAngle);
|
||||||
|
//targetRotation.y = Mathf.Clamp(targetRotation.y, minHorizontalAngle, maxHorizontalAngle);
|
||||||
|
targetDis = Mathf.Clamp(targetDis, minDis, maxDis);
|
||||||
|
currentDis = Mathf.SmoothDamp(currentDis, targetDis, ref disVelocity, rSmoothTime);
|
||||||
|
currentRotation = Vector3.SmoothDamp(currentRotation, targetRotation, ref rotVelocity, rSmoothTime);
|
||||||
|
var tmpRotation = Quaternion.Euler(currentRotation);
|
||||||
|
var offset = tmpRotation * Vector3.forward * -currentDis;
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
targetPosition = target.position;
|
||||||
|
}
|
||||||
|
currentPosition = Vector3.SmoothDamp(currentPosition, targetPosition, ref movVelocity, mSmoothTime);
|
||||||
|
var tmpPosition = currentPosition + offset;
|
||||||
|
if (transform.rotation != tmpRotation)
|
||||||
|
{
|
||||||
|
transform.rotation=tmpRotation;
|
||||||
|
}
|
||||||
|
if (ZhoLI)
|
||||||
|
{
|
||||||
|
if (transform.position.y > 3f)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(transform.position.x, 2.1f, transform.position.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (transform.position.y > 20f)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(transform.position.x, 20f, transform.position.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (transform.position.y < 2f)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(transform.position.x, 2.1f, transform.position.z);
|
||||||
|
}
|
||||||
|
if (Input.GetKey(KeyCode.LeftShift))
|
||||||
|
{
|
||||||
|
speed = 25f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
speed = 12f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float x= Mathf.Clamp(transform.position.x, -137f, 102f);
|
||||||
|
//float y = Mathf.Clamp(transform.position.y, 2.1f, 20f);
|
||||||
|
float z= Mathf.Clamp(transform.position.z, -125f, 119f);
|
||||||
|
transform.position = new Vector3(x,transform.position.y,z);
|
||||||
|
}
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
float x = Input.GetAxis("Horizontal");
|
||||||
|
float y = Input.GetAxis("Vertical");
|
||||||
|
float z = Input.GetAxis("Updown");
|
||||||
|
if (x != 0 || y != 0 || z != 0)
|
||||||
|
{
|
||||||
|
Debug.Log("Horizontal " + x + " Ver" + y);
|
||||||
|
if (!ZhoLI)
|
||||||
|
{
|
||||||
|
z = (z * Time.deltaTime * speed);
|
||||||
|
Debug.Log(z);
|
||||||
|
}
|
||||||
|
pos = new Vector3(x * Time.deltaTime * speed, z, y * Time.deltaTime * speed);
|
||||||
|
isok = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isok = false;
|
||||||
|
}
|
||||||
|
if (isok)
|
||||||
|
{
|
||||||
|
if (transform.position != pos || x != 0 || y != 0||z !=0)
|
||||||
|
{
|
||||||
|
transform.Translate(pos);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//public void Fly()
|
||||||
|
//{
|
||||||
|
// ZhoLI = false;
|
||||||
|
// transform.GetComponent<Rigidbody>().useGravity = false;
|
||||||
|
// transform.position = new Vector3(transform.position.x, 20f, transform.position.z);
|
||||||
|
//}
|
||||||
|
//public void NotFly()
|
||||||
|
//{
|
||||||
|
// ZhoLI = true;
|
||||||
|
// transform.GetComponent<Rigidbody>().useGravity = true;
|
||||||
|
// transform.position = new Vector3(transform.position.x,2.1f,transform.position.z);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
////声明部分public float horizontalinput;
|
||||||
|
/////水平参数public float Verticalinput;
|
||||||
|
/////垂直参数float speed=10.0f;
|
||||||
|
/////声明一个参数,没有规定
|
||||||
|
/////在update中书写
|
||||||
|
///void Update()
|
||||||
|
///{
|
||||||
|
///horizontalinput = Input.GetAxis("Horizontal");
|
||||||
|
/////AD方向控制Verticalinput = Input.GetAxis("Vertical");
|
||||||
|
///if (horizontalinput!=0&&Verticalinput!=0)
|
||||||
|
///{horizontalinput = horizontalinput * 0.6f;Verticalinput = Verticalinput * 0.6f;}
|
||||||
|
/////WS方向控制this.transform.Translate(Vector3.right * horizontalinput * Time.deltaTime * speed);
|
||||||
|
///控制该物体向侧方移动this.transform.Translate(Vector3.forward* Verticalinput * Time.deltaTime * speed);//控制该物体向前后移动}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 03962d1a310647749949f007b0d3edb7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,176 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using TMPro;
|
||||||
|
|
||||||
|
public class CameraControl1 : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public static CameraControl1 ins;
|
||||||
|
[Header("设置参数")]
|
||||||
|
[SerializeField] float minDis = 2;
|
||||||
|
[SerializeField] float maxDis ;
|
||||||
|
[SerializeField] float mouseRotSpeed = 8;
|
||||||
|
[SerializeField] float touchZoomSpeed = 0.1f;
|
||||||
|
[SerializeField] float touchRotateSpeed = 0.3f;
|
||||||
|
[SerializeField] float mouseMoveSpeed = 1;
|
||||||
|
[SerializeField] float mouseZoomSpeed = 10;
|
||||||
|
[SerializeField] float rSmoothTime = 0.3f;
|
||||||
|
[SerializeField] float sSmoothTime = 0.3f;
|
||||||
|
[SerializeField] float mSmoothTime = 0.3f;
|
||||||
|
[SerializeField] float minVerticalAngle = 0;
|
||||||
|
[SerializeField] float maxVerticalAngle = 60;
|
||||||
|
[Header("用于展示数据")]
|
||||||
|
[SerializeField] float horizontalAngle = 0;
|
||||||
|
[SerializeField] float verticalAngle = 0;
|
||||||
|
[SerializeField] float currentDis = 80;
|
||||||
|
[SerializeField] Vector3 originPosition;
|
||||||
|
[SerializeField] Vector3 targetPosition;
|
||||||
|
//[HideInInspector] public bool isrotateend;
|
||||||
|
bool isrotateable;
|
||||||
|
bool isscaleable;
|
||||||
|
float _targetDis;
|
||||||
|
private Touch oldTouch1;
|
||||||
|
private Touch oldTouch2;
|
||||||
|
//
|
||||||
|
public bool UPDOWN = false;
|
||||||
|
|
||||||
|
|
||||||
|
float targetDis
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_targetDis = value > maxDis ? maxDis : value < minDis ? minDis : value;
|
||||||
|
}
|
||||||
|
get { return _targetDis; }
|
||||||
|
}
|
||||||
|
Vector3 rVelocity = Vector3.zero;
|
||||||
|
float sVelocity = 0;
|
||||||
|
Vector3 mVelocity = Vector3.zero;
|
||||||
|
Vector3 dampRotation;
|
||||||
|
Transform targetTrans;
|
||||||
|
bool m_IsSingleFinger;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
ins = this;
|
||||||
|
targetDis = currentDis;
|
||||||
|
targetPosition = originPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ContextMenu("设置相机位置")]
|
||||||
|
private void SetCameraTrans()
|
||||||
|
{
|
||||||
|
transform.eulerAngles = new Vector3(verticalAngle, horizontalAngle, 0);
|
||||||
|
var offset = transform.forward * -currentDis;
|
||||||
|
transform.position = originPosition + offset;
|
||||||
|
}
|
||||||
|
public void SetTarget(Transform target, float distance = 4)
|
||||||
|
{
|
||||||
|
targetDis = distance;
|
||||||
|
targetTrans = target;
|
||||||
|
}
|
||||||
|
public void SetCenterPoint(Vector3 target, float distance = 4)
|
||||||
|
{
|
||||||
|
targetDis = distance;
|
||||||
|
targetPosition = target;
|
||||||
|
}
|
||||||
|
public void Recover(float max, float min)
|
||||||
|
{
|
||||||
|
|
||||||
|
// targetPosition = originPosition = Vector3.zero;
|
||||||
|
horizontalAngle -= horizontalAngle % 360;
|
||||||
|
verticalAngle = 0;
|
||||||
|
maxDis = max;
|
||||||
|
minDis = min;
|
||||||
|
targetDis = maxDis;
|
||||||
|
// targetTrans = null;
|
||||||
|
}
|
||||||
|
public void RecoverTwo()
|
||||||
|
{
|
||||||
|
horizontalAngle -= horizontalAngle % 360;
|
||||||
|
verticalAngle = 0;
|
||||||
|
targetDis = maxDis;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
//限制视角上下
|
||||||
|
if (UPDOWN)
|
||||||
|
{
|
||||||
|
if (verticalAngle < -15)
|
||||||
|
{
|
||||||
|
verticalAngle = -15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.touchCount == 0)
|
||||||
|
{
|
||||||
|
// isscaleable = true;
|
||||||
|
isrotateable = true;
|
||||||
|
if (Input.GetMouseButton(0))
|
||||||
|
{
|
||||||
|
horizontalAngle += Input.GetAxis("Mouse X") * mouseRotSpeed;
|
||||||
|
verticalAngle -= Input.GetAxis("Mouse Y") * mouseRotSpeed;
|
||||||
|
|
||||||
|
verticalAngle = Mathf.Clamp(verticalAngle, minVerticalAngle, maxVerticalAngle);
|
||||||
|
}
|
||||||
|
targetDis = targetDis - Input.GetAxis("Mouse ScrollWheel") * mouseZoomSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.touchCount == 1)
|
||||||
|
{
|
||||||
|
if (isrotateable)
|
||||||
|
{
|
||||||
|
if (Input.touches[0].phase == TouchPhase.Began)
|
||||||
|
{
|
||||||
|
oldTouch1 = Input.touches[0];
|
||||||
|
}
|
||||||
|
var deltaPos = Input.touches[0].position - oldTouch1.position;
|
||||||
|
horizontalAngle += deltaPos.x * touchRotateSpeed*3f ;
|
||||||
|
verticalAngle -= deltaPos.y * touchRotateSpeed;
|
||||||
|
verticalAngle = Mathf.Clamp(verticalAngle, minVerticalAngle, maxVerticalAngle);
|
||||||
|
oldTouch1 = Input.touches[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Input.touchCount == 2)
|
||||||
|
{
|
||||||
|
isrotateable = false ;
|
||||||
|
if (Input.touches[1].phase == TouchPhase.Began)
|
||||||
|
{
|
||||||
|
oldTouch1 = Input.touches[0];
|
||||||
|
oldTouch2 = Input.touches[1];
|
||||||
|
}
|
||||||
|
float currentTouchDistance = Vector2.Distance(Input.touches[0].position, Input.touches[1].position);
|
||||||
|
float lastTouchDistance = Vector2.Distance(oldTouch1.position, oldTouch2.position);
|
||||||
|
if (Input.touches[0].phase != TouchPhase.Ended && Input.touches[1].phase != TouchPhase.Ended)
|
||||||
|
{
|
||||||
|
//计算上次和这次双指触摸之间的距离差距
|
||||||
|
//然后去更改摄像机的距离
|
||||||
|
targetDis -= (currentTouchDistance - lastTouchDistance) * touchZoomSpeed;
|
||||||
|
oldTouch1 = Input.touches[0];
|
||||||
|
oldTouch2 = Input.touches[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentDis = Mathf.SmoothDamp(currentDis, targetDis, ref sVelocity, rSmoothTime);
|
||||||
|
dampRotation = Vector3.SmoothDamp(dampRotation, new Vector3(verticalAngle, horizontalAngle), ref rVelocity, rSmoothTime);
|
||||||
|
transform.rotation = Quaternion.Euler(dampRotation);
|
||||||
|
if (targetTrans != null)
|
||||||
|
{
|
||||||
|
if (originPosition != targetTrans.position)
|
||||||
|
originPosition = Vector3.SmoothDamp(originPosition, targetTrans.position, ref mVelocity, mSmoothTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (originPosition != targetPosition)
|
||||||
|
originPosition = Vector3.SmoothDamp(originPosition, targetPosition, ref mVelocity, mSmoothTime);
|
||||||
|
}
|
||||||
|
var offset = transform.forward * -currentDis;
|
||||||
|
transform.position = originPosition + offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5eb279537374e4e4d8f1ad4cf74d2b06
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,18 +1,28 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour
|
public class GameManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static GameManager ins;
|
public static GameManager ins;
|
||||||
|
public GameObject Player;
|
||||||
public CameraManager CameraManager;
|
public CameraManager CameraManager;
|
||||||
List<GameObject> tools;
|
List<GameObject> tools;
|
||||||
[SerializeField] GameObject g1;
|
[SerializeField] GameObject QianXing;
|
||||||
char[] g2 = new char[7] {'(','C','l','o','n','e',')' };
|
[SerializeField] GameObject WanYon;
|
||||||
public void Awake()
|
[SerializeField] GameObject YanDianBi;
|
||||||
|
char[] TempChar = new char[7] {'(','C','l','o','n','e',')' };
|
||||||
|
public string dataStr;
|
||||||
|
[SerializeField] List<datas> Datas= new List<datas>();
|
||||||
|
[SerializeField] List<GameObject> GFGame;//光伏板物体
|
||||||
|
[SerializeField] SceneData SceneData;//暂时数据
|
||||||
|
[SerializeField] List<GameObject> Inverter;
|
||||||
|
public void AwakeAsync()
|
||||||
{
|
{
|
||||||
if (ins!=null)
|
if (ins!=null)
|
||||||
{
|
{
|
||||||
|
@ -20,22 +30,78 @@ public class GameManager : MonoBehaviour
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ins = this;
|
ins = this;
|
||||||
|
|
||||||
}
|
}
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
async void Start()
|
||||||
{
|
{
|
||||||
ToolsShow(g1);
|
await initAsync();
|
||||||
|
for (int i = 0; i < SceneData.GFData; i++)
|
||||||
|
{
|
||||||
|
GFGame[i].gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < SceneData.inverterSum; i++)
|
||||||
|
{
|
||||||
|
Inverter[i].gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async Task initAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Datas.Add(await HttpTool.GetJsonAsync<datas>($"http://111.229.30.246:10013/Handler/Taiqu.ashx?action=changjing&bianhao={dataStr}"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if(Input.GetKeyDown(KeyCode.Q))
|
||||||
|
{
|
||||||
|
ToolsShow(QianXing);
|
||||||
|
}
|
||||||
|
//if(Input.GetKeyDown(KeyCode.W))
|
||||||
|
//{
|
||||||
|
// ToolsShow(WanYon);
|
||||||
|
//}
|
||||||
|
if(Input.GetKeyDown(KeyCode.E))
|
||||||
|
{
|
||||||
|
ToolsShow(YanDianBi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ¹¤¾ßÉú³É·½·¨
|
/// ¹¤¾ßÉú³É·½·¨
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ToolsShow(GameObject tools)
|
public void ToolsShow(GameObject tools)
|
||||||
{
|
{
|
||||||
GameObject temp = Instantiate(tools);
|
GameObject temp = Instantiate(tools, Player.transform);
|
||||||
string name = Filter(temp.name,g2);
|
temp.transform.localPosition = new Vector3(0.319f,-0.471f,0.87f);
|
||||||
|
temp.transform.localRotation = Quaternion.Euler(new Vector3(90,180,0));
|
||||||
|
temp.AddComponent<ClampAmmeters>();
|
||||||
|
string name = Filter(temp.name,TempChar);
|
||||||
Debug.Log(name);
|
Debug.Log(name);
|
||||||
switch (temp.name)
|
switch (name)
|
||||||
{
|
{
|
||||||
|
case "万用表":
|
||||||
|
break;
|
||||||
|
case "钳形电流表":
|
||||||
|
ToolModelClick tool = temp.GetComponent<ToolModelClick>();
|
||||||
|
ClampAmmeters clamp = temp.GetComponent<ClampAmmeters>();
|
||||||
|
//tool.onDown.AddListener(clamp.MouseDown);
|
||||||
|
tool.onDrag.AddListener(() =>
|
||||||
|
{
|
||||||
|
clamp.isok = true;
|
||||||
|
});
|
||||||
|
tool.onExit.AddListener(() =>
|
||||||
|
{
|
||||||
|
clamp.isok = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "":
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -46,3 +112,20 @@ public class GameManager : MonoBehaviour
|
||||||
return String.Concat(str.Split(charsToRemove.ToArray()));
|
return String.Concat(str.Split(charsToRemove.ToArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 后台读的数据
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class datas
|
||||||
|
{
|
||||||
|
public bool state;
|
||||||
|
public string message;
|
||||||
|
public data2s data;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class data2s
|
||||||
|
{
|
||||||
|
public string isguangfu;
|
||||||
|
public string jxfs;
|
||||||
|
public string zhbl;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
|
public class HttpTool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// get
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="uri"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<T> GetJsonAsync<T>(string uri)
|
||||||
|
{
|
||||||
|
Debug.Log("akjsbd");
|
||||||
|
using (var uwr = UnityWebRequest.Get(uri))
|
||||||
|
{
|
||||||
|
await uwr.SendWebRequest();
|
||||||
|
if (uwr.isNetworkError)
|
||||||
|
{
|
||||||
|
Debug.LogError(uwr.error);
|
||||||
|
return default(T);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log(JsonUtility.FromJson<T>(uwr.downloadHandler.text));
|
||||||
|
return JsonUtility.FromJson<T>(uwr.downloadHandler.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//if (uwr.result == UnityWebRequest.Result.Success)
|
||||||
|
// return JsonUtility.FromJson<T>(uwr.downloadHandler.text);
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// Debug.LogError(uwr.error);
|
||||||
|
// return default(T);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Post±íµ¥
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="uri"></param>
|
||||||
|
/// <param name="keyValuePairs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<T> PostFromAsync<T>(string uri, Dictionary<string, string> keyValuePairs)
|
||||||
|
{
|
||||||
|
WWWForm formData = new WWWForm();
|
||||||
|
foreach (var item in keyValuePairs)
|
||||||
|
{
|
||||||
|
formData.AddField(item.Key, item.Value);
|
||||||
|
}
|
||||||
|
using (var uwr = UnityWebRequest.Post(uri, formData))
|
||||||
|
{
|
||||||
|
await uwr.SendWebRequest();
|
||||||
|
if (uwr.isNetworkError)
|
||||||
|
{
|
||||||
|
Debug.LogError(uwr.error);
|
||||||
|
return default(T);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return JsonUtility.FromJson<T>(uwr.downloadHandler.text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// PostJson
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="uri"></param>
|
||||||
|
/// <param name="jsonObject"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<T> PostJsonAysnc<T>(string uri, object jsonObject)
|
||||||
|
{
|
||||||
|
var jsonString = JsonUtility.ToJson(jsonObject);
|
||||||
|
// Debug.Log(jsonString);
|
||||||
|
var postData = System.Text.Encoding.Default.GetBytes(jsonString);
|
||||||
|
using (var uwr = new UnityWebRequest(uri, "POST"))
|
||||||
|
{
|
||||||
|
uwr.SetRequestHeader("Content-type", "application/json");
|
||||||
|
uwr.uploadHandler = new UploadHandlerRaw(postData);
|
||||||
|
uwr.downloadHandler = new DownloadHandlerBuffer();
|
||||||
|
await uwr.SendWebRequest();
|
||||||
|
if (uwr.isNetworkError)
|
||||||
|
{
|
||||||
|
Debug.LogError(uwr.error);
|
||||||
|
return default(T);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Debug.Log(uwr.downloadHandler.text+"£º·¢Ë͵½£º"+uwr );
|
||||||
|
return JsonUtility.FromJson<T>(uwr.downloadHandler.text);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dd4f45ed7bc2b4e4698d826bc4b7760c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -37,6 +37,8 @@ public class LoaclInterObjectWatch : MonoBehaviour
|
||||||
onClick();
|
onClick();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//onClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ToolsMove : MonoBehaviour
|
||||||
|
{
|
||||||
|
ToolModelClick toolModelClick;
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
//Debug.Log("dada");
|
||||||
|
//toolModelClick.enter.AddListener(EnterTTT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnterTTT()
|
||||||
|
{
|
||||||
|
Debug.Log("OnMouseEnter");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMouseEnter()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMouseDown()
|
||||||
|
{
|
||||||
|
Debug.Log(transform.name);
|
||||||
|
}
|
||||||
|
private void OnMouseDrag()
|
||||||
|
{
|
||||||
|
Debug.Log(transform.name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f833184ffe9580645a0630d2857ac1b1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -8,10 +8,10 @@ using System;
|
||||||
/// Version: 1.0 alpha 1
|
/// Version: 1.0 alpha 1
|
||||||
///
|
///
|
||||||
/// - Use "ToAudioClip" method for loading wav file / bytes.
|
/// - Use "ToAudioClip" method for loading wav file / bytes.
|
||||||
/// Loads .wav (PCM uncompressed) files at 8,16,24 and 32 bits and converts data to Unity's AudioClip.
|
/// Loads .wav (PCM uncompressed) files at 8,16,24 and 32 bits and converts datas to Unity's AudioClip.
|
||||||
///
|
///
|
||||||
/// - Use "FromAudioClip" method for saving wav file / bytes.
|
/// - Use "FromAudioClip" method for saving wav file / bytes.
|
||||||
/// Converts an AudioClip's float data into wav byte array at 16 bit.
|
/// Converts an AudioClip's float datas into wav byte array at 16 bit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// For documentation and usage examples: https://github.com/deadlyfingers/UnityWav
|
/// For documentation and usage examples: https://github.com/deadlyfingers/UnityWav
|
||||||
|
@ -23,7 +23,7 @@ public class WavTool
|
||||||
const int BlockSize_16Bit = 2;
|
const int BlockSize_16Bit = 2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load PCM format *.wav audio file (using Unity's Application data path) and convert to AudioClip.
|
/// Load PCM format *.wav audio file (using Unity's Application datas path) and convert to AudioClip.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The AudioClip.</returns>
|
/// <returns>The AudioClip.</returns>
|
||||||
/// <param name="filePath">Local file path to .wav file</param>
|
/// <param name="filePath">Local file path to .wav file</param>
|
||||||
|
@ -31,7 +31,7 @@ public class WavTool
|
||||||
{
|
{
|
||||||
if (!filePath.StartsWith(Application.persistentDataPath) && !filePath.StartsWith(Application.dataPath))
|
if (!filePath.StartsWith(Application.persistentDataPath) && !filePath.StartsWith(Application.dataPath))
|
||||||
{
|
{
|
||||||
Debug.LogWarning("This only supports files that are stored using Unity's Application data path. \nTo load bundled resources use 'Resources.Load(\"filename\") typeof(AudioClip)' method. \nhttps://docs.unity3d.com/ScriptReference/Resources.Load.html");
|
Debug.LogWarning("This only supports files that are stored using Unity's Application datas path. \nTo load bundled resources use 'Resources.Load(\"filename\") typeof(AudioClip)' method. \nhttps://docs.unity3d.com/ScriptReference/Resources.Load.html");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
byte[] fileBytes = File.ReadAllBytes(filePath);
|
byte[] fileBytes = File.ReadAllBytes(filePath);
|
||||||
|
@ -89,7 +89,7 @@ public class WavTool
|
||||||
{
|
{
|
||||||
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
||||||
headerOffset += sizeof(int);
|
headerOffset += sizeof(int);
|
||||||
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 8-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 8-bit wav size: {0} from datas bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
||||||
|
|
||||||
float[] data = new float[wavSize];
|
float[] data = new float[wavSize];
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class WavTool
|
||||||
{
|
{
|
||||||
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
||||||
headerOffset += sizeof(int);
|
headerOffset += sizeof(int);
|
||||||
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 16-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 16-bit wav size: {0} from datas bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
||||||
|
|
||||||
int x = sizeof(Int16); // block size = 2
|
int x = sizeof(Int16); // block size = 2
|
||||||
int convertedSize = wavSize / x;
|
int convertedSize = wavSize / x;
|
||||||
|
@ -127,7 +127,7 @@ public class WavTool
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav data is wrong size: {0} == {1}", data.Length, convertedSize);
|
Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav datas is wrong size: {0} == {1}", data.Length, convertedSize);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class WavTool
|
||||||
{
|
{
|
||||||
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
||||||
headerOffset += sizeof(int);
|
headerOffset += sizeof(int);
|
||||||
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 24-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 24-bit wav size: {0} from datas bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
||||||
|
|
||||||
int x = 3; // block size = 3
|
int x = 3; // block size = 3
|
||||||
int convertedSize = wavSize / x;
|
int convertedSize = wavSize / x;
|
||||||
|
@ -157,7 +157,7 @@ public class WavTool
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav data is wrong size: {0} == {1}", data.Length, convertedSize);
|
Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav datas is wrong size: {0} == {1}", data.Length, convertedSize);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ public class WavTool
|
||||||
{
|
{
|
||||||
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
int wavSize = BitConverter.ToInt32(source, headerOffset);
|
||||||
headerOffset += sizeof(int);
|
headerOffset += sizeof(int);
|
||||||
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 32-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, "Failed to get valid 32-bit wav size: {0} from datas bytes: {1} at offset: {2}", wavSize, dataSize, headerOffset);
|
||||||
|
|
||||||
int x = sizeof(float); // block size = 4
|
int x = sizeof(float); // block size = 4
|
||||||
int convertedSize = wavSize / x;
|
int convertedSize = wavSize / x;
|
||||||
|
@ -184,7 +184,7 @@ public class WavTool
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav data is wrong size: {0} == {1}", data.Length, convertedSize);
|
Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav datas is wrong size: {0} == {1}", data.Length, convertedSize);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ public class WavTool
|
||||||
UInt16 bitDepth = 16; //BitDepth (audioClip);
|
UInt16 bitDepth = 16; //BitDepth (audioClip);
|
||||||
|
|
||||||
// NB: Only supports 16 bit
|
// NB: Only supports 16 bit
|
||||||
//Debug.AssertFormat (bitDepth == 16, "Only converting 16 bit is currently supported. The audio clip data is {0} bit.", bitDepth);
|
//Debug.AssertFormat (bitDepth == 16, "Only converting 16 bit is currently supported. The audio clip datas is {0} bit.", bitDepth);
|
||||||
|
|
||||||
// total file size = 44 bytes for header format and audioClip.samples * factor due to float to Int16 / sbyte conversion
|
// total file size = 44 bytes for header format and audioClip.samples * factor due to float to Int16 / sbyte conversion
|
||||||
int fileSize = audioClip.samples * BlockSize_16Bit + headerSize; // BlockSize (bitDepth)
|
int fileSize = audioClip.samples * BlockSize_16Bit + headerSize; // BlockSize (bitDepth)
|
||||||
|
@ -216,7 +216,7 @@ public class WavTool
|
||||||
WriteFileHeader(ref stream, fileSize);
|
WriteFileHeader(ref stream, fileSize);
|
||||||
// file header (fmt)
|
// file header (fmt)
|
||||||
WriteFileFormat(ref stream, audioClip.channels, audioClip.frequency, bitDepth);
|
WriteFileFormat(ref stream, audioClip.channels, audioClip.frequency, bitDepth);
|
||||||
// data chunks (data)
|
// datas chunks (datas)
|
||||||
WriteFileData(ref stream, audioClip, bitDepth);
|
WriteFileData(ref stream, audioClip, bitDepth);
|
||||||
|
|
||||||
byte[] bytes = stream.ToArray();
|
byte[] bytes = stream.ToArray();
|
||||||
|
@ -304,25 +304,25 @@ public class WavTool
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int total = 8;
|
int total = 8;
|
||||||
|
|
||||||
// Copy float[] data from AudioClip
|
// Copy float[] datas from AudioClip
|
||||||
float[] data = new float[audioClip.samples * audioClip.channels];
|
float[] data = new float[audioClip.samples * audioClip.channels];
|
||||||
audioClip.GetData(data, 0);
|
audioClip.GetData(data, 0);
|
||||||
|
|
||||||
byte[] bytes = ConvertAudioClipDataToInt16ByteArray(data);
|
byte[] bytes = ConvertAudioClipDataToInt16ByteArray(data);
|
||||||
|
|
||||||
byte[] id = Encoding.ASCII.GetBytes("data");
|
byte[] id = Encoding.ASCII.GetBytes("datas");
|
||||||
count += WriteBytesToMemoryStream(ref stream, id, "DATA_ID");
|
count += WriteBytesToMemoryStream(ref stream, id, "DATA_ID");
|
||||||
|
|
||||||
int subchunk2Size = Convert.ToInt32(audioClip.samples * BlockSize_16Bit); // BlockSize (bitDepth)
|
int subchunk2Size = Convert.ToInt32(audioClip.samples * BlockSize_16Bit); // BlockSize (bitDepth)
|
||||||
count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(subchunk2Size), "SAMPLES");
|
count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(subchunk2Size), "SAMPLES");
|
||||||
|
|
||||||
// Validate header
|
// Validate header
|
||||||
Debug.AssertFormat(count == total, "Unexpected wav data id byte count: {0} == {1}", count, total);
|
Debug.AssertFormat(count == total, "Unexpected wav datas id byte count: {0} == {1}", count, total);
|
||||||
|
|
||||||
// Write bytes to stream
|
// Write bytes to stream
|
||||||
count += WriteBytesToMemoryStream(ref stream, bytes, "DATA");
|
count += WriteBytesToMemoryStream(ref stream, bytes, "DATA");
|
||||||
|
|
||||||
// Validate audio data
|
// Validate audio datas
|
||||||
Debug.AssertFormat(bytes.Length == subchunk2Size, "Unexpected AudioClip to wav subchunk2 size: {0} == {1}", bytes.Length, subchunk2Size);
|
Debug.AssertFormat(bytes.Length == subchunk2Size, "Unexpected AudioClip to wav subchunk2 size: {0} == {1}", bytes.Length, subchunk2Size);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: af0cb5cf014e6284692f1826af15c057
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ǯÐÎǯÐεçÁ÷±í
|
||||||
|
/// </summary>
|
||||||
|
public class ClampAmmeters : MonoBehaviour
|
||||||
|
{
|
||||||
|
//private Vector3 offset;
|
||||||
|
//public void MouseDown()
|
||||||
|
//{
|
||||||
|
// offset = GetMouseWorldPos();
|
||||||
|
//}
|
||||||
|
Vector3 pos;
|
||||||
|
public bool isok = false;
|
||||||
|
public void MouseDrag()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (Input.GetMouseButton(0))
|
||||||
|
{
|
||||||
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||||
|
RaycastHit hitInfo;
|
||||||
|
|
||||||
|
if (Physics.Raycast(ray, out hitInfo))
|
||||||
|
{
|
||||||
|
if (pos!= hitInfo.point)
|
||||||
|
{
|
||||||
|
transform.GetComponent<BoxCollider>().isTrigger= true;
|
||||||
|
transform.position = hitInfo.point;
|
||||||
|
pos = hitInfo.point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b36d48c576bc3ff48a2626d3e0b2bd76
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be8f397fe039a2c439fa6f298560bdd4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class SceneData : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] int OperatingCapacity;//运行容量
|
||||||
|
[SerializeField] int FixedValue = 295;//固定容量
|
||||||
|
public int GFData;//光伏板数量=运行容量/固定容量,取int值
|
||||||
|
public int inverterSum = 2;
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
//Global
|
||||||
|
GFData = OperatingCapacity / FixedValue;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7d6add50eadc99948962f0eb8a109a41
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -35,12 +35,12 @@
|
||||||
"source": "builtin",
|
"source": "builtin",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.ide.visualstudio": "2.0.16",
|
"com.unity.ide.visualstudio": "2.0.16",
|
||||||
"com.unity.ide.rider": "3.0.15",
|
"com.unity.ide.rider": "3.0.16",
|
||||||
"com.unity.ide.vscode": "1.2.5",
|
"com.unity.ide.vscode": "1.2.5",
|
||||||
"com.unity.editorcoroutines": "1.0.0",
|
"com.unity.editorcoroutines": "1.0.0",
|
||||||
"com.unity.performance.profile-analyzer": "1.1.1",
|
"com.unity.performance.profile-analyzer": "1.1.1",
|
||||||
"com.unity.test-framework": "1.1.31",
|
"com.unity.test-framework": "1.1.31",
|
||||||
"com.unity.testtools.codecoverage": "1.0.1"
|
"com.unity.testtools.codecoverage": "1.2.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.unity.ide.rider": {
|
"com.unity.ide.rider": {
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
"url": "https://packages.unity.cn"
|
"url": "https://packages.unity.cn"
|
||||||
},
|
},
|
||||||
"com.unity.services.core": {
|
"com.unity.services.core": {
|
||||||
"version": "1.4.2",
|
"version": "1.6.0",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
"url": "https://packages.unity.cn"
|
"url": "https://packages.unity.cn"
|
||||||
},
|
},
|
||||||
"com.unity.testtools.codecoverage": {
|
"com.unity.testtools.codecoverage": {
|
||||||
"version": "1.0.1",
|
"version": "1.2.2",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
Loading…
Reference in New Issue