修复BUG
This commit is contained in:
@@ -35,3 +35,24 @@ public class ModuleAssets<Data> {
|
|||||||
/// <summary> 循环列表 </summary>
|
/// <summary> 循环列表 </summary>
|
||||||
public virtual void ForEach(Action<Data> action) => Datas.ForEach(action);
|
public virtual void ForEach(Action<Data> action) => Datas.ForEach(action);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 资源模块工具
|
||||||
|
/// </summary>
|
||||||
|
public static class ModuleAssetsTool {
|
||||||
|
/// <summary> 头尾循环标准化索引 </summary>
|
||||||
|
public static Data LoopIndex<Data>(this ModuleAssets<Data> assets, int index) {
|
||||||
|
return assets[LoopIndex(index, assets.Count)];
|
||||||
|
}
|
||||||
|
/// <summary> 头尾循环标准化索引 </summary>
|
||||||
|
public static Data LoopIndex<Data>(this List<Data> list, int index) {
|
||||||
|
return list[LoopIndex(index, list.Count)];
|
||||||
|
}
|
||||||
|
/// <summary> 头尾循环标准化索引 </summary>
|
||||||
|
public static Data LoopIndex<Data>(this Data[] array, int index) {
|
||||||
|
return array[LoopIndex(index, array.Length)];
|
||||||
|
}
|
||||||
|
/// <summary> 头尾循环标准化索引 </summary>
|
||||||
|
public static int LoopIndex(int index, int maxIndex) {
|
||||||
|
return index % maxIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,3 +8,14 @@ using UnityEngine;
|
|||||||
public class ModuleCore : Module<ModuleCore> {
|
public class ModuleCore : Module<ModuleCore> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 模块基类
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="ModuleCore"></typeparam>
|
||||||
|
public class Module<ModuleCore> where ModuleCore : Module<ModuleCore>, new() {
|
||||||
|
/// <summary> 模块单例 </summary>
|
||||||
|
public static ModuleCore I => Instantiate();
|
||||||
|
|
||||||
|
private static ModuleCore core;
|
||||||
|
private static ModuleCore Instantiate() => core == null ? core = new ModuleCore() : core;
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public static class LoopIndexTool {
|
|
||||||
/// <summary> 头尾循环标准化索引 </summary>
|
|
||||||
public static Data LoopIndex<Data>(this List<Data> list, int index) {
|
|
||||||
return list[LoopIndex(index, list.Count)];
|
|
||||||
}
|
|
||||||
/// <summary> 头尾循环标准化索引 </summary>
|
|
||||||
public static Data LoopIndex<Data>(this Data[] array, int index) {
|
|
||||||
return array[LoopIndex(index, array.Length)];
|
|
||||||
}
|
|
||||||
/// <summary> 头尾循环标准化索引 </summary>
|
|
||||||
public static int LoopIndex(int index, int maxIndex) {
|
|
||||||
if (maxIndex == 0) { Debug.LogError("错误索引:maxIndex = 0"); return 0; }
|
|
||||||
if (index < 0) { return LoopIndex(index + maxIndex, maxIndex); }
|
|
||||||
if (index >= maxIndex) { return LoopIndex(index - maxIndex, maxIndex); }
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f410a5e521f087048804a823d1c02e6c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: de13e4c89e97faf45b5d383070fd8e5e
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 模块基类
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="ModuleCore"></typeparam>
|
|
||||||
public class Module<ModuleCore> where ModuleCore : Module<ModuleCore>, new() {
|
|
||||||
/// <summary> 模块单例 </summary>
|
|
||||||
public static ModuleCore I => Instantiate();
|
|
||||||
|
|
||||||
private static ModuleCore core;
|
|
||||||
private static ModuleCore Instantiate() => core == null ? core = new ModuleCore() : core;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 86acb6fd9f576cc458df7bcc1581c098
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Reference in New Issue
Block a user