This commit is contained in:
CortexCore
2023-06-05 16:25:06 +08:00
parent 9027120bb8
commit 4565ff2e35
2947 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
{
"name": "BITKit.ObjectMaterial",
"rootNamespace": "",
"references": [
"GUID:a209c53514018594f9f482516f2a6781",
"GUID:274d4ecae4648e94c8b2cee7218378a0",
"GUID:66d2ae14764cc7d49aad4b16930747c0",
"GUID:14fe60d984bf9f84eac55c6ea033a8f4"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [
"ODIN_INSPECTOR"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit.ObjectMaterial
{
public class GetObjectMaterialByCollider : MonoBehaviour, IObjectMaterial
{
public ObjectMaterialScriptableObject material;
public ObjectMaterialInfo GetObjectMaterial(string action = "None", Vector3 pos = default)
{
return material.dictionary[action];
}
}
}

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RotaryHeart.Lib.SerializableDictionary;
namespace BITKit.ObjectMaterial
{
[System.Serializable]
public struct ObjectMaterialInfo
{
public AudioSO[] clips;
public Transform[] prefabs;
public AudioSO GetAudioSO() => clips.Random();
public Transform GetPrefab() => prefabs.Random();
}
public interface IObjectMaterial
{
ObjectMaterialInfo GetObjectMaterial(string action = "None", Vector3 pos = default);
}
public class ObjectMaterialScriptableObject : BITKitSO
{
[Header(Constant.Header.Settings)]
public new string name;
[Header(Constant.Header.Prefabs)]
public SerializableDictionaryBase<string, ObjectMaterialInfo> dictionary = new();
public override void RegisterAssets()
{
Data.Set<ObjectMaterialScriptableObject>(name, this);
dictionary.Values.ForEach(x =>
{
x.clips.ForEach(x =>
{
Data.Set<AudioSO>(x.name, x);
});
x.prefabs.ForEach(x=>
{
Data.Set<Transform>(x.name,x);
});
});
}
public ObjectMaterialInfo Get(string name)=>dictionary[name];
}
}