refactor: Update Unity to 2022.3.62

This commit is contained in:
2025-06-21 01:22:02 +08:00
parent d71bf7d4a5
commit 283783954f
112 changed files with 778 additions and 907 deletions

View File

@@ -14,7 +14,7 @@ namespace Cryville.Crtr.Skin.Components {
SubmitProperty("zindex", new PropOp.Integer(v => ZIndex = (short)v));
}
protected MeshWrapper mesh = new MeshWrapper();
protected MeshWrapper mesh = new();
protected Material[] materials;
short _zindex;

View File

@@ -6,13 +6,13 @@ using UnityEngine;
namespace Cryville.Crtr.Skin.Components {
public class PolygonSGO : SectionalGameObject {
static readonly SimpleObjectPool<List<Vector3>> _ptPool = new SimpleObjectPool<List<Vector3>>(1024);
static readonly SimpleObjectPool<List<float>> _lPool = new SimpleObjectPool<List<float>>(1024);
static readonly SimpleObjectPool<List<Vector3>> _ptPool = new(1024);
static readonly SimpleObjectPool<List<float>> _lPool = new(1024);
static readonly ListPool<int> _indexPool = new ListPool<int>();
static readonly ListPool<Vector3> _vertPool = new ListPool<Vector3>();
static readonly ListPool<Vector2> _uvPool = new ListPool<Vector2>();
static readonly ArrayPool<Vector2> _shapePool = new ArrayPool<Vector2>(0x100, 0x10000);
static readonly ListPool<int> _indexPool = new();
static readonly ListPool<Vector3> _vertPool = new();
static readonly ListPool<Vector2> _uvPool = new();
static readonly ArrayPool<Vector2> _shapePool = new(0x100, 0x10000);
public PolygonSGO() {
SubmitProperty("head", new PropOp.String(v => head.FrameName = v));
@@ -50,9 +50,9 @@ namespace Cryville.Crtr.Skin.Components {
return r;
}
public SpriteInfo head = new SpriteInfo();
public SpriteInfo body = new SpriteInfo();
public SpriteInfo tail = new SpriteInfo();
public SpriteInfo head = new();
public SpriteInfo body = new();
public SpriteInfo tail = new();
List<Vector3> vertices;
List<float> lengths;
@@ -104,7 +104,7 @@ namespace Cryville.Crtr.Skin.Components {
List<Vector3> verts;
List<Vector2> uvs;
List<int> trih = null, trib = null, trit = null;
static readonly List<int> _emptyTris = new List<int>();
static readonly List<int> _emptyTris = new();
public override void Seal() {
if (vertCount <= 1 || sumLength == 0) return;

View File

@@ -27,8 +27,7 @@ namespace Cryville.Crtr.Skin.Components {
}
else {
var id = new Identifier(value);
AnimationSpan anim;
if (!ChartPlayer.pskin.animations.TryGetValue(id, out anim)) {
if (!ChartPlayer.pskin.animations.TryGetValue(id, out AnimationSpan anim)) {
Game.MainLogger.Log(4, "Skin", "Animation {0} not found", id.Name);
_anim = null;
return;

View File

@@ -45,7 +45,7 @@ namespace Cryville.Crtr.Skin.Components {
}
else Frame = null;
if (_mat != null) {
_mat.mainTexture = Frame == null ? null : Frame.Texture;
_mat.mainTexture = Frame?.Texture;
}
}
public static bool IsNullOrEmpty(SpriteInfo sprite) {
@@ -88,7 +88,7 @@ namespace Cryville.Crtr.Skin.Components {
OnFrameUpdate();
}
}
SpriteInfo[] m_frames = new SpriteInfo[] { new SpriteInfo() };
SpriteInfo[] m_frames = new SpriteInfo[] { new() };
public string[] Frames {
set {
m_frames = new SpriteInfo[value.Length];
@@ -169,12 +169,12 @@ namespace Cryville.Crtr.Skin.Components {
protected override Vector3 BaseScale {
get {
switch (m_fit) {
case FitMode.none: return Vector3.one;
case FitMode.width: return new Vector3(1, 1, 1 / CurrentFrame.Ratio);
case FitMode.height: return new Vector3(CurrentFrame.Ratio, 1, 1);
default: throw new NotSupportedException("Unsupported fit mode");
}
return m_fit switch {
FitMode.none => Vector3.one,
FitMode.width => new Vector3(1, 1, 1 / CurrentFrame.Ratio),
FitMode.height => new Vector3(CurrentFrame.Ratio, 1, 1),
_ => throw new NotSupportedException("Unsupported fit mode"),
};
}
}

View File

@@ -9,7 +9,7 @@ namespace Cryville.Crtr.Skin.Components {
}
static readonly Dictionary<float, int> uvrefl
= new Dictionary<float, int>() {
= new() {
{-0.5f, 0}, {-0.4f, 1}, {0.4f, 2}, {0.5f, 3},
};
static Vector2[] _origuv;
@@ -30,7 +30,7 @@ namespace Cryville.Crtr.Skin.Components {
}
}
Vector2 _border = new Vector2(0, 1);
Vector2 _border = new(0, 1);
public Vector2 Border {
get { return _border; }
set {
@@ -67,12 +67,12 @@ namespace Cryville.Crtr.Skin.Components {
case 3: x = 1; bx = 1; break;
default: throw new NotSupportedException("Built-in resource corrupted");
}
float y;
switch ((int)muv[i].y) {
case 0: y = 0; break;
case 3: y = 1; break;
default: throw new NotSupportedException("Built-in resource corrupted");
}
var y = (int)muv[i].y switch {
0 => 0,
3 => (float)1,
_ => throw new NotSupportedException("Built-in resource corrupted"),
};
_uvs[i] = frame.Frame.GetUV(x, y);
bx -= 0.5f; y -= 0.5f;
_verts[i] = new Vector3(bx, 0, y);

View File

@@ -22,8 +22,7 @@ namespace Cryville.Crtr.Skin.Components {
protected override unsafe void Execute() {
var keys = GetOperand(0).AsString();
var values = GetOperand(1);
int arrtype; int len;
values.GetArraySuffix(out arrtype, out len);
values.GetArraySuffix(out int arrtype, out int len);
if (arrtype != PdtInternalType.String) throw new InvalidCastException("Not an array of strings");
if (len != keys.Length) throw new ArgumentException("Length of key not equal to frame count");
var result = new Dictionary<char, SpriteInfo>(len);
@@ -49,7 +48,7 @@ namespace Cryville.Crtr.Skin.Components {
set { m_frames = value; UpdateFrames(); }
}
readonly TargetString m_value = new TargetString();
readonly TargetString m_value = new();
public TargetString Value { get { return m_value; } }
public float m_size;
@@ -103,10 +102,10 @@ namespace Cryville.Crtr.Skin.Components {
}
float sum_x;
readonly Dictionary<Texture2D, MeshWrapper> meshes = new Dictionary<Texture2D, MeshWrapper>();
readonly Dictionary<Texture2D, List<Vector3>> verts = new Dictionary<Texture2D, List<Vector3>>();
readonly Dictionary<Texture2D, List<Vector2>> uvs = new Dictionary<Texture2D, List<Vector2>>();
readonly Dictionary<Texture2D, List<int>> tris = new Dictionary<Texture2D, List<int>>();
readonly Dictionary<Texture2D, MeshWrapper> meshes = new();
readonly Dictionary<Texture2D, List<Vector3>> verts = new();
readonly Dictionary<Texture2D, List<Vector2>> uvs = new();
readonly Dictionary<Texture2D, List<int>> tris = new();
void UpdateMeshes() {
if (meshes.Count == 0) return;
sum_x = 0;
@@ -117,8 +116,7 @@ namespace Cryville.Crtr.Skin.Components {
tris[key].Clear();
}
foreach (var c in m_value) {
SpriteInfo f;
if (!m_frames.TryGetValue(c, out f)) {
if (!m_frames.TryGetValue(c, out SpriteInfo f)) {
Game.MainLogger.Log(3, "Skin", "Could not render the character '{0}' in the string \"{1}\" on the text component because no image is assigned to that character.", c, m_value);
continue;
}
@@ -173,7 +171,7 @@ namespace Cryville.Crtr.Skin.Components {
UpdateFrames();
mesh.Mesh.Clear();
UpdateScale();
Value.OnUpdate += UpdateScale;
Value.Updated += UpdateScale;
}
}
}

View File

@@ -3,7 +3,7 @@ using UnityEngine;
namespace Cryville.Crtr.Skin.Components {
public class TrackLine : SectionalGameObject {
readonly List<Vector3> vertices = new List<Vector3>();
readonly List<Vector3> vertices = new();
LineRenderer lineRenderer;