赞
踩
目录
测试的时候,如果有多个class,可以写到一个文件中;多个文件的没有测试
放到Unity工程的Asset->Plugins文件夹下。“虽然”这个操作没有起作用,但是还是规范下比较好。
本地操作可以正常使用,但是后面的打包WebGL却有问题
出现过找不到DLLNotFond的问题;不报错但是读取配置文件,没有值的问题
解决方案:主场景中创建一个空物体,将DLL文件挂载上去;
- public class MonoSingletonBase<T> : MonoBehaviour where T : MonoBehaviour
- {
- private static object _singletonLock = new object();
-
- private static T _instance;
-
- public static T Instance
- {
- get
- {
- if (_instance == null)
- {
- lock (_singletonLock)
- {
- T[] singletonInstances = FindObjectsOfType(typeof(T)) as T[];
- if (singletonInstances.Length == 0) return null;
-
- if (singletonInstances.Length > 1)
- {
- if (Application.isEditor)
- UnityEngine.Debug.LogWarning(
- "MonoSingleton<T>.Instance: Only 1 singleton instance can exist in the scene. Null will be returned.");
- return null;
- }
-
- _instance = singletonInstances[0];
- }
- }
-
- return _instance;
- }
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。