引用测试

main
pengjunwu 2024-02-20 18:50:36 +08:00
parent 28e75d50bb
commit 089b6d64cb
2 changed files with 118 additions and 24 deletions

View File

@ -15,6 +15,7 @@ using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement;
using CharacterInfo = Gameplay.Net.CharacterInfo;
using Constants = Framework.Constants;
using Object = UnityEngine.Object;
public partial class SROptions
@ -22,29 +23,84 @@ public partial class SROptions
private List<Material> _testMatList = new();
[Category("Test")]
public void TestMonoScriptReference()
public void TestMonoScriptReferenceStart()
{
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);
Addressables.Release(mat);
Debug.LogError($"test reference:{_testMatList[0].name}");
}
[Category("Test")]
public void TestUnityObjectReference()
public void TestMonoScriptReferenceEnd()
{
var go = new GameObject("test");
var test = go.AddComponent<TestUnityObjectReference>();
test.Test();
var path =
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
Addressables.Release(_testMatList[0]);
Debug.LogError($"test reference:{_testMatList[0].name}");
}
private TestUnityObjectReference TestUnityObjectReference
{
get
{
var result = Object.FindObjectOfType<TestUnityObjectReference>();
if (result == null)
{
var go = new GameObject("test");
result = go.AddComponent<TestUnityObjectReference>();
}
return result;
}
}
[Category("Test")]
public void TestUnityObjectSerializableReference()
public void TestUnityObjectReferenceStart()
{
var go = new GameObject("test");
var test = go.AddComponent<TestUnityObjectReference>();
test.TestSerializable();
TestUnityObjectReference.Test();
}
[Category("Test")]
public void TestUnityObjectReferenceEnd()
{
TestUnityObjectReference.TestEnd();
}
[Category("Test")]
public void TestUnityObjectSerializableReferenceStart()
{
TestUnityObjectReference.TestSerializable();
}
[Category("Test")]
public void TestUnityObjectSerializableReferenceEnd()
{
TestUnityObjectReference.TestSerializableEnd();
}
[Category("Test")]
public void TestSingleUnityObjectReferenceStart()
{
TestUnityObjectReference.TestSingleStart();
}
[Category("Test")]
public void TestSingleUnityObjectReferenceEnd()
{
TestUnityObjectReference.TestSingleEnd();
}
[Category("Test")]
public void TestSingleSerializableUnityObjectReferenceStart()
{
TestUnityObjectReference.TestSingleSerializableStart();
}
[Category("Test")]
public void TestSingleSerializableUnityObjectReferenceEnd()
{
TestUnityObjectReference.TestSingleSerializableEnd();
}
}

View File

@ -5,15 +5,13 @@ using UnityEngine.AddressableAssets;
public class TestUnityObjectReference : MonoBehaviour
{
private Material _testMat;
public Material serializableTestMat;
private List<Material> _testMatList = new();
public List<Material> serializableTestMatList = new();
// Start is called before the first frame update
void Start()
{
}
public void Test()
{
@ -21,8 +19,15 @@ public class TestUnityObjectReference : MonoBehaviour
"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);
Addressables.Release(mat);
Debug.LogError($"test reference:{_testMatList[0].name}");
Debug.LogError($"Test:{_testMatList[0].name}");
}
public void TestEnd()
{
var path =
"Assets/Art/AutoGen/PostProcessScenes/Assets_Scenes_CampScene/Combined/NLD_URP_NLD_Scene_Lambert/CombieMat.mat";
Addressables.Release(_testMatList[0]);
Debug.LogError($"TestEnd:{_testMatList[0].name}");
}
public void TestSerializable()
@ -31,13 +36,46 @@ public class TestUnityObjectReference : MonoBehaviour
"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);
Addressables.Release(mat);
Debug.LogError($"test reference:{serializableTestMatList[0].name}");
Debug.LogError($"TestSerializable:{serializableTestMatList[0].name}");
}
// Update is called once per frame
void Update()
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}");
}
}