暂且修了LookAt

This commit is contained in:
SoulliesOfficial
2025-07-13 06:06:38 -04:00
parent 7642bf1d9d
commit b00eb6505b
52 changed files with 32852 additions and 16272 deletions

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class ColorExtensions
{
public static Gradient DefaultGradient()
{
Gradient gradient = new Gradient();
GradientColorKey[] colorKeys = new GradientColorKey[2];
colorKeys[0].color = Color.white;
colorKeys[0].time = 0;
colorKeys[1].color = Color.white;
colorKeys[1].time = 1;
GradientAlphaKey[] alphaKeys = new GradientAlphaKey[2];
alphaKeys[0].alpha = 1;
alphaKeys[0].time = 0;
alphaKeys[1].alpha = 1;
alphaKeys[1].time = 1;
gradient.SetKeys(colorKeys, alphaKeys);
return gradient;
}
}

View File

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

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni
{
/// <summary>
/// 自定义曲线预设
/// </summary>
public static class CustomCurvePresets
{
/// <summary>
/// 瞬间完成
/// </summary>
/// <returns></returns>
public static AnimationCurve Instant()
{
Keyframe[] keys = new Keyframe[2];
keys[0] = new Keyframe(0, 1, 0, 0);
keys[1] = new Keyframe(1, 1, 0, 0);
return new AnimationCurve(keys);
}
/// <summary>
/// 抛物线曲线,在中间达到最大值,两端为起始值
/// </summary>
/// <param name="totalTime">总时间</param>
/// <param name="startValue">起始(和结束)值</param>
/// <param name="peakValue">中点最大值</param>
public static AnimationCurve Parabolic(float totalTime, float startValue, float peakValue)
{
Keyframe[] keys = new Keyframe[3];
keys[0] = new Keyframe(0, startValue, 0, 0);
keys[1] = new Keyframe(totalTime / 2, peakValue, 0, 0);
keys[2] = new Keyframe(totalTime, startValue, 0, 0);
return new AnimationCurve(keys);
}
/// <summary>
/// 自定义峰值点位置的抛物线曲线,在指定时间点达到最大值,两端为起始值
/// </summary>
/// <param name="totalTime">总时间</param>
/// <param name="startValue">起始(和结束)值</param>
/// <param name="peakValue">最大值</param>
/// <param name="peakTimePercent">最大值的比例点</param>
/// <returns></returns>
public static AnimationCurve CustomPeakTimeParabolic(float totalTime, float startValue, float peakValue, float peakTimePercent)
{
Keyframe[] keys = new Keyframe[3];
keys[0] = new Keyframe(0, startValue, 0, 0);
keys[1] = new Keyframe(totalTime * peakTimePercent, peakValue, 0, 0);
keys[2] = new Keyframe(totalTime, startValue, 0, 0);
return new AnimationCurve(keys);
}
}
}

View File

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

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public static class ListExtension
{
public static Vector3 Sum(this List<Vector3> list)
{
return list.Aggregate(Vector3.zero, (current, addition) => current + addition);
}
}

View File

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

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class ShaderExtension
{
/// <summary>
/// 对于从AssetBundle中加载的材质修改Shader参数可能会出现异常情况。
/// 此时需要在生成物体的时候重新初始化Shader。
/// </summary>
public static void InitializeShader(this Renderer renderer)
{
foreach (Material material in renderer.materials)
{
string shaderName = material.shader.name;
Shader shader = Shader.Find(shaderName);
if (shader != null)
{
material.shader = shader;
}
else
{
Debug.LogWarning($"Shader '{shaderName}' not found for material '{material.name}' on renderer '{renderer.name}'.");
}
}
}
}

View File

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