添加bool3,在inspecter中展示为横着的三个勾选框,但是保存为一个整数(๑•̀ㅂ•́)و✧

This commit is contained in:
2023-11-25 15:58:36 +08:00
parent 7cbe59ca14
commit f67b26667b
17 changed files with 494 additions and 20 deletions
+35
View File
@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XericLibrary.Runtime.Type;
namespace XericLibrary.Runtime.CollisionLOD
{
public class LodBoxCollider : LodColliderBase
{
#region 字段属性
/// <summary>
/// 启用轴向
/// </summary>
public Bool3 EnableCollisionAxis = new Bool3(1,0,1);
#endregion
#region 生命周期
#endregion
#region 碰撞检测
private bool CheckCollision()
{
return false;
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 05ae1487ca501af4583c3f2d5307c5b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+12
View File
@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace XericLibrary.Runtime.CollisionLOD
{
public class LodSphereCollider : LodColliderBase
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6882978c69b0a1f40b440f8ef70f8fc2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d3709d62d6ccbc40acfb2b368f8aa5b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,120 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using XericLibrary.Runtime.Type;
namespace XericLibrary.Runtime.CollisionLOD
{
/// <summary>
/// 具有基本缩放的碰撞器基类
/// </summary>
public abstract class LodColliderBase : WeaklyMonoBase , IComparable
{
/*
* 碰撞体需要及时性,不建议使用协程,异步等方法处理事件
*/
#region 静态成员
#region 字段属性
/// <summary>
/// 碰撞处理流程
/// </summary>
protected static ProgramFlowLinear ProgramFlow;
#endregion
#region 静态方法
#endregion
#endregion
#region 字段属性
/// <summary>
/// 处理等级
/// </summary>
public int SeqLevels = -1;
/// <summary>
/// 表示序列等级是否不需要处理
/// </summary>
[SerializeField]
private bool noInitializationRequired = false;
/// <summary>
/// 盒体尺寸信息
/// </summary>
public Bounds BoundSize;
/// <summary>
/// 碰撞器集合
/// </summary>
private List<LodColliderBase> allLodColliderList = null;
#endregion
#region 生命周期
private void OnValidate()
{
noInitializationRequired = true;
var allColliders = transform.GetComponents<LodColliderBase>();
if(SeqLevels < 0)
SeqLevels = allColliders.Length;
var genList = allColliders.ToList();
MakeLevelLinearArray(genList);
}
private void Start()
{
if(noInitializationRequired)
return;
// 动态添加的处理
//allLodColliderList = transform.GetComponents<LodColliderBase>()
//.ToList();
//MakeLevelLinearArray(allLodColliderList);
}
#endregion
#region 方法
/// <summary>
/// 使列表等级完全不重复
/// </summary>
private void MakeLevelLinearArray(List<LodColliderBase> genList)
{
genList.Sort();
int seqIndex = 0;
foreach(var item in genList)
item.SeqLevels = seqIndex++;
}
#endregion
#region 接口
public int CompareTo(object obj)
{
if(obj is LodColliderBase lod)
return SeqLevels.CompareTo(lod.SeqLevels);
else
return this.CompareTo(obj);
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 306fe8a0033a9e74bb27f07803ead32b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: