This commit is contained in:
2025-11-14 18:44:06 +08:00
parent 10156da245
commit 22e867d077
7013 changed files with 2572882 additions and 1804 deletions

View File

@@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Buterfly
{
public Transform objectRef;
public Vector3 targetPos;
Vector3 randomPos;
public Buterfly(Transform objectRef, Vector3 targetPos)
{
this.objectRef = objectRef;
this.targetPos = targetPos;
}
public void Ai()
{
if(Vector3.Distance(objectRef.position, targetPos) < 0.1f)
{
targetPos = GetRandomPos(objectRef.parent.position);
}
else
{
//objectRef.position = Vector3.Lerp(objectRef.position, targetPos, Time.deltaTime * 2);
objectRef.Translate(Vector3.forward * Time.deltaTime * 2f);
objectRef.rotation = Quaternion.Lerp(objectRef.rotation, Quaternion.LookRotation(targetPos - objectRef.position, objectRef.forward), Time.deltaTime * 2);
}
}
public static Vector3 GetRandomPos(Vector3 origionPos)
{
return origionPos + new Vector3(Random.Range(-2, 2f), Random.Range(0, 2f), Random.Range(-2, 2f));
}
}
public class ButerflyMain : MonoBehaviour
{
public int count;
public GameObject buterflyRes;
public Buterfly[] buterflies;
// Start is called before the first frame update
void Start()
{
buterflies = new Buterfly[count];
for(int i = 0; i < count; ++i)
{
GameObject clone = Instantiate(buterflyRes, Buterfly.GetRandomPos(transform.position), Quaternion.Euler(Vector3.right * Random.Range(0, 360f)), transform);
buterflies[i] = new Buterfly(clone.transform, Buterfly.GetRandomPos(transform.position));
buterflies[i].objectRef.GetComponent<MeshRenderer>().material.SetFloat("_Index", Random.Range(0, 9));
}
}
// Update is called once per frame
void Update()
{
if (Vector3.Distance(transform.position, Camera.main.transform.position) > 30) { return; }
for (int i = 0; i < count; ++i)
{
buterflies[i].Ai();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 55995580a03bb384d82ff596598ef337
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,128 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class CharProperties
{
public float moveSpeed;
public float moveSpeedPlus;
public float rotSpeed;
public float gravity;
public float jumpHeight;
}
public class CharProxyMain : MonoBehaviour
{
float deltaTime;
public Camera viewCam;
public CharacterController characterController;
public bool isHeadShake;
public Animation headShakeAnim;
string animationRecord;
public CharProperties charProperties;
public Vector3 moveDir;
public Vector3 rotDir;
float moveSpeedPlusTemp;
void Start()
{
}
void Update()
{
deltaTime = Time.deltaTime;
//
CursuorAction();
CameraAction();
MoveAction();
if(Input.GetKeyDown(KeyCode.Escape))
{
Application.Quit();
}
}
public void CursuorAction()
{
if (Input.GetMouseButton(1))
{
Cursor.lockState = CursorLockMode.Locked;
}
else
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
public void CameraAction()
{
if (Input.GetMouseButton(1))
{
rotDir.x += Input.GetAxis("Mouse X") * charProperties.rotSpeed * deltaTime;
rotDir.y -= Input.GetAxis("Mouse Y") * charProperties.rotSpeed * deltaTime;
rotDir.y = Mathf.Clamp(rotDir.y, -90, 90);
viewCam.transform.localRotation = Quaternion.Euler(new Vector3(rotDir.y, 0, 0));
transform.rotation = Quaternion.Euler(new Vector3(0, rotDir.x, 0));
}
if (isHeadShake && (characterController.isGrounded && (moveDir.x != 0 || moveDir.z != 0)))
{
if (animationRecord != "ANIM_HeadShake")
{
animationRecord = "ANIM_HeadShake";
headShakeAnim.CrossFade(animationRecord, 0.25f);
}
}
else
{
animationRecord = "ANIM_HeadShakeEnd";
headShakeAnim.CrossFade(animationRecord, 0.25f);
}
}
public void MoveAction()
{
if (Input.GetKey(KeyCode.LeftShift))
{
moveSpeedPlusTemp = charProperties.moveSpeedPlus;
headShakeAnim[animationRecord].speed = charProperties.moveSpeedPlus / 2f;
}
else
{
moveSpeedPlusTemp = 1;
headShakeAnim[animationRecord].speed = 1;
}
//
moveDir.x = Input.GetAxis("Horizontal") * charProperties.moveSpeed * moveSpeedPlusTemp;
moveDir.z = Input.GetAxis("Vertical") * charProperties.moveSpeed * moveSpeedPlusTemp;
if (characterController.isGrounded)
{
if (Input.GetButtonDown("Jump"))
{
moveDir.y = charProperties.jumpHeight;
}
else
{
moveDir.y = -1;
}
}
else
{
moveDir.y -= charProperties.gravity;
}
moveDir = transform.TransformDirection(moveDir);
characterController.Move(moveDir * deltaTime);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2574ce58d143ee9428bb806707345be0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class CharacterRotationFollow : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector3(0, Time.deltaTime * 10, 0));
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0512e04ab34b1941a7fe06d1a124fd4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FreeView : MonoBehaviour
{
Vector3 rotDir;
public float rotSpeed;
float deltaTime;
public Camera viewCam;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
deltaTime = Time.deltaTime;
CursuorAction();
CameraAction();
}
public void CursuorAction()
{
if (Input.GetMouseButton(1))
{
Cursor.lockState = CursorLockMode.Locked;
}
else
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
public void CameraAction()
{
if (Input.GetMouseButton(1))
{
rotDir.x += Input.GetAxis("Mouse X") * rotSpeed * deltaTime;
rotDir.y -= Input.GetAxis("Mouse Y") * rotSpeed * deltaTime;
rotDir.y = Mathf.Clamp(rotDir.y, -90, 90);
viewCam.transform.localRotation = Quaternion.Euler(new Vector3(rotDir.y, 0, 0));
transform.rotation = Quaternion.Euler(new Vector3(0, rotDir.x, 0));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: feb643cc2aa410841a56d60190565054
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HitBMain : MonoBehaviour
{
RaycastHit hit;
public Material mat;
GameObject hitTag;
// Start is called before the first frame update
void Start()
{
hitTag = GameObject.CreatePrimitive(PrimitiveType.Quad);
hitTag.transform.localScale = Vector3.one * 0.5f;
hitTag.GetComponent<MeshRenderer>().material = mat;
Destroy(hitTag.GetComponent<MeshCollider>());
}
// Update is called once per frame
void Update()
{
if (Physics.Raycast(new Ray(Camera.main.transform.position, Camera.main.transform.forward), out hit, 1, 1 << LayerMask.NameToLayer("Wall")))
{
hitTag.SetActive(true);
hitTag.transform.position = hit.point;
hitTag.transform.rotation = Quaternion.LookRotation(Camera.main.transform.forward);
}
else
{
hitTag.SetActive(false);
}
}
private void OnDrawGizmos()
{
//Gizmos.color = Color.green;
//Gizmos.DrawRay(Camera.main.transform.position, Camera.main.transform.forward * 1);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6394b74e2988bbf4fac2e4a188602134
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
public class MoveFollow : MonoBehaviour
{
public float speed;
public Transform path;
Transform[] pathPoints;
int index;
Vector3 mouseDir;
void Start()
{
pathPoints = path.GetComponentsInChildren<Transform>();
pathPoints[0] = transform;
}
void Update()
{
if(Vector3.Distance(transform.position, pathPoints[index].position) < 1f)
{
++index;
if(index >= pathPoints.Length)
{
index = 0;
}
}
transform.Translate((pathPoints[index].position - transform.position) * Time.deltaTime * speed);
if(Input.GetMouseButton(1))
{
mouseDir.x -= Input.GetAxis("Mouse Y") * Time.deltaTime * 800;
mouseDir.y += Input.GetAxis("Mouse X") * Time.deltaTime * 800;
Camera.main.transform.localRotation = Quaternion.Euler(mouseDir);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 507483154ffd0ba46ad7951a184cd623
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using UnityEngine;
using System.Collections.Generic;
public class ShowTrisCount : MonoBehaviour
{
void Start()
{
int totalFaces = 0;
MeshFilter[] meshFilters = FindObjectsOfType<MeshFilter>();
foreach (MeshFilter m in meshFilters)
{
if(m.mesh && m.mesh.isReadable)
{
totalFaces += m.mesh.triangles.Length / 3;
}
}
Debug.Log("Total faces in the scene: " + totalFaces);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3672780a4afbf8b46a1162ac86afbd44
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,122 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Wethermain : MonoBehaviour
{
public Transform[] ts;
bool aaa;
bool bbb;
float time;
float timeB;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
if(aaa)
{
aaa = false;
}
else
{
aaa = true;
}
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
if (bbb)
{
bbb = false;
}
else
{
bbb = true;
}
}
if (aaa)
{
time += Time.deltaTime * 2;
}
else
{
time -= Time.deltaTime * 2;
}
time = Mathf.Clamp(time, 0, 1);
asdasd(time);
//
if (bbb)
{
timeB += Time.deltaTime * 2;
}
else
{
timeB -= Time.deltaTime * 2;
}
timeB = Mathf.Clamp(timeB, 0, 1);
asdasdd(timeB);
}
void asdasd(float v)
{
foreach (Transform t in ts)
{
foreach (Transform tt in t.GetComponentsInChildren<Transform>())
{
if (tt.GetComponent<MeshRenderer>())
{
foreach (Material m in tt.GetComponent<MeshRenderer>().materials)
{
if (m.HasFloat("_Snownny"))
{
m.SetFloat("_Snownny", v);
}
}
}
//
if (tt.GetComponent<Grass>())
{
Material m = tt.GetComponent<Grass>().material;
m.SetFloat("_Snownny", v);
}
}
}
}
void asdasdd(float v)
{
foreach (Transform t in ts)
{
foreach (Transform tt in t.GetComponentsInChildren<Transform>())
{
if (tt.GetComponent<MeshRenderer>())
{
foreach (Material m in tt.GetComponent<MeshRenderer>().materials)
{
if (m.HasFloat("_Rainny"))
{
m.SetFloat("_Rainny", v);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ece6bf21a9c98854c8b4dbc7dac7763b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: