89 lines
3.3 KiB
C#
89 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.AddressableAssets;
|
|
using UnityEngine.UI;
|
|
|
|
public class TestUnityObjectReference : MonoBehaviour
|
|
{
|
|
private Material _testMat;
|
|
|
|
public Material serializableTestMat;
|
|
|
|
private List<Material> _testMatList = new();
|
|
|
|
public List<Material> serializableTestMatList = new();
|
|
|
|
public void Test()
|
|
{
|
|
// var path =
|
|
// "Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
|
|
// var mat = Addressables.LoadAssetAsync<Material>(path).WaitForCompletion();
|
|
// _testMatList.Add(mat);
|
|
// Debug.LogError($"Test:{_testMatList[0].name}");
|
|
|
|
var path =
|
|
"Assets/Art/UI/Texture/Poster/Poster_Default/Poster_A00001.png";
|
|
var sprite = Addressables.LoadAssetAsync<Sprite>(path).WaitForCompletion();
|
|
var image = gameObject.GetComponent<Image>()?? gameObject.AddComponent<Image>();
|
|
image.sprite = sprite;
|
|
Debug.LogError($"Test:{sprite.name}");
|
|
}
|
|
|
|
public void TestEnd()
|
|
{
|
|
var image = gameObject.GetComponent<Image>()?? gameObject.AddComponent<Image>();
|
|
Addressables.Release(image.sprite);
|
|
Debug.LogError($"TestEnd:{image.sprite == null}");
|
|
}
|
|
|
|
public void TestSerializable()
|
|
{
|
|
var path =
|
|
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
|
|
var mat = Addressables.LoadAssetAsync<Material>(path).WaitForCompletion();
|
|
serializableTestMatList.Add(mat);
|
|
Debug.LogError($"TestSerializable:{serializableTestMatList[0].name}");
|
|
}
|
|
|
|
public void TestSerializableEnd()
|
|
{
|
|
var path =
|
|
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
|
|
Addressables.Release(serializableTestMatList[0]);
|
|
Debug.LogError($"TestSerializableEnd:{serializableTestMatList[0].name}");
|
|
}
|
|
|
|
public void TestSingleStart()
|
|
{
|
|
var path =
|
|
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
|
|
_testMat = Addressables.LoadAssetAsync<Material>(path).WaitForCompletion();
|
|
Debug.LogError($"TestSingleStart:{_testMat.name}");
|
|
}
|
|
|
|
public void TestSingleEnd()
|
|
{
|
|
var path =
|
|
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
|
|
Addressables.Release(_testMat);
|
|
Debug.LogError($"TestSingleEnd:{_testMat.name}");
|
|
}
|
|
|
|
public void TestSingleSerializableStart()
|
|
{
|
|
var path =
|
|
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
|
|
serializableTestMat = Addressables.LoadAssetAsync<Material>(path).WaitForCompletion();
|
|
Debug.LogError($"TestSingleSerializableStart:{serializableTestMat.name}");
|
|
}
|
|
|
|
public void TestSingleSerializableEnd()
|
|
{
|
|
var path =
|
|
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
|
|
Addressables.Release(serializableTestMat);
|
|
Debug.LogError($"TestSingleSerializableEnd:{serializableTestMat.name}");
|
|
}
|
|
}
|