1
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user