WIP: load litmodel base on player pos
This commit is contained in:
@@ -15,7 +15,7 @@ MonoBehaviour:
|
||||
m_DefaultGroup: 712e3991f28e549e7a56ee582a977810
|
||||
m_currentHash:
|
||||
serializedVersion: 2
|
||||
Hash: 53f136d91da384ffd70238725c18c22d
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_OptimizeCatalogSize: 0
|
||||
m_BuildRemoteCatalog: 0
|
||||
m_CatalogRequestsTimeout: 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ MonoBehaviour:
|
||||
m_Id: 506465302ec864e8eb6eb8e0d2ee7b2c
|
||||
m_LoadPath:
|
||||
m_Id: 71015b41342024feebebb329061472f1
|
||||
m_BundleMode: 1
|
||||
m_BundleMode: 0
|
||||
m_AssetBundleProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ MonoBehaviour:
|
||||
m_Id: 506465302ec864e8eb6eb8e0d2ee7b2c
|
||||
m_LoadPath:
|
||||
m_Id: 71015b41342024feebebb329061472f1
|
||||
m_BundleMode: 1
|
||||
m_BundleMode: 0
|
||||
m_AssetBundleProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,8 @@ namespace BrewMonster
|
||||
{
|
||||
public static class AddressableTools
|
||||
{
|
||||
private static string _modelPathPrefixToRemove = "Assets/ModelRenderer/Art/Models";
|
||||
private static string _gfxPathPrefixToRemove = "Assets/ModelRenderer/Art/Gfx";
|
||||
public static string _modelPathPrefixToRemove = "Assets/ModelRenderer/Art/Models";
|
||||
public static string _gfxPathPrefixToRemove = "Assets/ModelRenderer/Art/Gfx";
|
||||
|
||||
[MenuItem("Tools/Addressable/Get All Asset Name")]
|
||||
public static void GetAllAssetName()
|
||||
@@ -76,6 +76,12 @@ namespace BrewMonster
|
||||
UpdateAddressableAddressesPath("gfx", _gfxPathPrefixToRemove, ".gfx");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Addressable/Update Addressable Path For a61")]
|
||||
public static void UpdateAddressablePathFora61()
|
||||
{
|
||||
UpdateAddressableAddressesPath("a61", _modelPathPrefixToRemove, "");
|
||||
}
|
||||
|
||||
public static void UpdateAddressableAddressesPath(string groupName, string prefixToRemove, string subfix)
|
||||
{
|
||||
AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using BrewMonster.Scripts;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
@@ -6,11 +8,12 @@ public class AddressableObject : MonoBehaviour
|
||||
{
|
||||
public string assetPath;
|
||||
|
||||
public async void LoadAsset()
|
||||
public async UniTask LoadAsset()
|
||||
{
|
||||
var model = await AddressableManager.Instance.LoadPrefabAsync(assetPath);
|
||||
if (model != null)
|
||||
{
|
||||
model = Instantiate(model);
|
||||
var modelTransform = model.transform;
|
||||
modelTransform.SetParent(transform);
|
||||
modelTransform.localPosition = Vector3.zero;
|
||||
@@ -24,4 +27,35 @@ public class AddressableObject : MonoBehaviour
|
||||
{
|
||||
AddressableManager.Instance.ReleaseAsset(assetPath);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static string _modelPathPrefixToRemove = "Assets/ModelRenderer/Art/Models";
|
||||
[ContextMenu("Get Asset Path")]
|
||||
public void GetAssetPath()
|
||||
{
|
||||
var prefabObject = PrefabUtility.GetCorrespondingObjectFromSource(this.gameObject);
|
||||
if (prefabObject != null)
|
||||
{
|
||||
var path = AssetDatabase.GetAssetPath(prefabObject);
|
||||
//remove the prefix from the path
|
||||
path = path.Substring(_modelPathPrefixToRemove.Length + 1);
|
||||
//remove the .prefab suffix
|
||||
path = path.Substring(0, path.Length - ".prefab".Length);
|
||||
assetPath = path;
|
||||
|
||||
// now delete all the children of this object
|
||||
while (transform.childCount > 0)
|
||||
{
|
||||
DestroyImmediate(transform.GetChild(0).gameObject);
|
||||
}
|
||||
|
||||
//unpack completely the prefab
|
||||
PrefabUtility.UnpackPrefabInstance(this.gameObject, PrefabUnpackMode.Completely, InteractionMode.UserAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("No prefab object found for this object");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,7 +1,57 @@
|
||||
using BrewMonster.Scripts;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class LitModelHolder : MonoBehaviour
|
||||
{
|
||||
public AssetReference[] modelReferences;
|
||||
[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
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8d097871fd2de79f64a6527f97d2043554bfa5ead80936e385e2353b5b8375b4
|
||||
size 200515435
|
||||
oid sha256:2b36ad83acfce998e47fd8d2a57accdbf89d0299c143f4d116522316e50700b5
|
||||
size 196456189
|
||||
|
||||
Reference in New Issue
Block a user