1
This commit is contained in:
21
Unity/Scripts/ObjectMaterial/BITKit.ObjectMaterial.asmdef
Normal file
21
Unity/Scripts/ObjectMaterial/BITKit.ObjectMaterial.asmdef
Normal 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
|
||||
}
|
14
Unity/Scripts/ObjectMaterial/GetObjectMaterialByCollider.cs
Normal file
14
Unity/Scripts/ObjectMaterial/GetObjectMaterialByCollider.cs
Normal 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];
|
||||
}
|
||||
}
|
||||
}
|
@@ -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