57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using BrewMonster.Scripts;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
public class LitModelHolder : MonoBehaviour
|
|
{
|
|
[SerializeField] private AddressableObject[] addressableObjects;
|
|
|
|
private async void Awake()
|
|
{
|
|
if (!AddressableManager.Instance.IsInitialized())
|
|
{
|
|
await UniTask.DelayFrame(1);
|
|
}
|
|
|
|
await LoadAllAddressableObjects();
|
|
}
|
|
|
|
// for debug
|
|
private Vector3 centerPos = new Vector3(-771.7f, 47.5f, -261.0f);
|
|
private async UniTask LoadAllAddressableObjects()
|
|
{
|
|
foreach (var addressableObject in addressableObjects)
|
|
{
|
|
if ((addressableObject.transform.position - centerPos).magnitude > 100f)
|
|
{
|
|
continue;
|
|
}
|
|
await addressableObject.LoadAsset();
|
|
await UniTask.DelayFrame(1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
[SerializeField] private GameObject[] originalObjects;
|
|
|
|
[ContextMenu("Setup Addressable Objects")]
|
|
public void SetupAddressableObjects()
|
|
{
|
|
foreach (var originalObject in originalObjects)
|
|
{
|
|
var addressableObject = originalObject.GetComponent<AddressableObject>();
|
|
if (addressableObject == null)
|
|
{
|
|
addressableObject = originalObject.AddComponent<AddressableObject>();
|
|
}
|
|
|
|
if (addressableObject != null)
|
|
{
|
|
addressableObject.GetAssetPath();
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
} |