测试Unity引用机制

main
pengjunwu 2024-02-20 17:29:36 +08:00
parent 7a8fbfcd81
commit 28e75d50bb
5 changed files with 117 additions and 1 deletions

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Cysharp.Threading.Tasks;
using Framework;
using Framework.Wrapper;
using Gameplay;
using Gameplay.Area;
using Gameplay.Character;
using Gameplay.Level;
using Gameplay.SubSystems;
using PhxhSDK;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement;
using CharacterInfo = Gameplay.Net.CharacterInfo;
using Constants = Framework.Constants;
public partial class SROptions
{
private List<Material> _testMatList = new();
[Category("Test")]
public void TestMonoScriptReference()
{
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()
{
var go = new GameObject("test");
var test = go.AddComponent<TestUnityObjectReference>();
test.Test();
}
[Category("Test")]
public void TestUnityObjectSerializableReference()
{
var go = new GameObject("test");
var test = go.AddComponent<TestUnityObjectReference>();
test.TestSerializable();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06a6924b9ed041d4abc7b853ed382329
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,43 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
public class TestUnityObjectReference : MonoBehaviour
{
private List<Material> _testMatList = new();
public List<Material> serializableTestMatList = new();
// Start is called before the first frame update
void Start()
{
}
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);
Addressables.Release(mat);
Debug.LogError($"test reference:{_testMatList[0].name}");
}
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);
Addressables.Release(mat);
Debug.LogError($"test reference:{serializableTestMatList[0].name}");
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73ed889f55cf9af4e97ecdc94f41dbf8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -557,7 +557,8 @@ public class UI_LevelSelectController : UIWindow
if (_currSelectLevelInfo.IsStory)
LevelManager.Instance.TryEnterLevel(_currSelectLevelInfo.ID);
else
UIManager.Instance.OpenWindow(UINameConst.UI_LevelDetail, _currSelectLevelInfo);
UIManager.Instance.OpenWindow(UINameConst.UI_BeforeFight, _currSelectLevelInfo.ID);
//UIManager.Instance.OpenWindow(UINameConst.UI_LevelDetail, _currSelectLevelInfo);
//LevelManager.Instance.TryEnterLevel(_currSelectLevelInfo.ID, CloseSelf);
}