TUIO unity模拟器


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);
}
}
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)