资源简介

TUIO模拟器,可以自定义设置发送端口和接收端口,在没有硬件的情况下可以自行测试使用,同时还是Unity原工程,可以加压缩后直接使用unity打开研究

资源截图

代码片段和文件信息

/*

Singleton MonoBehaviour

Generic Unity MonoBehaviour Singleton

Usage:
public class MusicManager : SingletonMonobehaviour {
public void PlaySong(string name) {}
}

To survive scene loads use DontDestroyonload(this) in subclasses or use SingletonMonobehaviourNoDestroy.
nb. this ONLY works if any parents of the gameobject aren‘t themselves destroyed! ie. should be at root level or nested in another non-destructible gameobject.

Updated 24/5/2015
Copyright Flightless 2014. All rights reserved.

*/

using UnityEngine;
using System.Collections.Generic;

namespace Flightless {

public abstract class SingletonMonoBehaviour : MonoBehaviour where T : SingletonMonoBehaviour {

private static T _instance;
public static T instance { get { return _instance ?? (!isApplicationQuitting ? new Gameobject(“_“ + typeof(T)).AddComponent() : null ); } }
public static T CreateInstance() { return instance; }
public static bool hasInstance { get { return _instance != null; } }

public static bool isApplicationQuitting { get; protected set; }


virtual protected void Awake() {
if (_instance != null) {
Debug.LogError(name + “.Awake() error: already initialised as “ + _instance.name);
Destroy(gameobject);
return;
}

_instance = (T)this;
Initialise();
}

virtual protected void Initialise() {}

virtual protected void OnApplicationQuit() {
isApplicationQuitting = true;
}

virtual protected void OnDestroy() {
if (_instance == this) _instance = null;
}
}


public abstract class SingletonMonoBehaviourNoDestroy : SingletonMonoBehaviour where T : SingletonMonoBehaviourNoDestroy {

override protected void Awake() {
base.Awake();
DontDestroyonload(gameobject);
}
}
}

评论

共有 条评论