BITKit/Packages/Runtime~/Unity/Common/Scripts/ObjectMaterial/ObjectMaterialScriptableObj...

28 lines
907 B
C#
Raw Normal View History

2023-06-05 19:57:17 +08:00
using System.Collections;
using System.Collections.Generic;
2023-07-17 10:23:47 +08:00
using AYellowpaper.SerializedCollections;
2023-06-05 19:57:17 +08:00
using UnityEngine;
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);
}
2023-07-17 10:23:47 +08:00
public class ObjectMaterialScriptableObject : ScriptableObject
2023-06-05 19:57:17 +08:00
{
[Header(Constant.Header.Settings)]
public new string name;
[Header(Constant.Header.Prefabs)]
2023-07-17 10:23:47 +08:00
public SerializedDictionary<string, ObjectMaterialInfo> dictionary = new();
public ObjectMaterialInfo Get(string _name)=>dictionary[_name];
2023-06-05 19:57:17 +08:00
}
}