void OnDestroy() { if (libcsv != null) { LibCSV.unInitLib(); } }
void Start() { string path = Application.dataPath; string sdkpath = path + "/../SDKDLL"; libcsv = LibCSV.InitLib(sdkpath); tex = new Texture2D(1280, 720, TextureFormat.RGBA32, false); GetComponent <UITexture>().mainTexture = tex; StartCoroutine("Display"); }
// Use this for initialization public void Start() { // string path = Application.dataPath; string sdkpath = path + "/../SDKDLL"; libcsv = LibCSV.InitLib(sdkpath); txt2dtest = new Texture2D(1280, 720, TextureFormat.RGBA32, false); GameObject.FindGameObjectWithTag("Game1BG").GetComponent <UITexture>().mainTexture = txt2dtest; }
/// <summary> /// 每隔 1.0f / 26 秒播放一帧动画 /// </summary> IEnumerator Display() { while (true) { byte[] videoData = LibCSV.GetCurrentVideoData(); if (tex != null && videoData != null) { if (videoData.Length == tex.width * tex.height * 4) { tex.LoadRawTextureData(videoData); tex.Apply(); LibCSV.SetWrite(); } } yield return(new WaitForSeconds(1.0f / 26)); } }
void Update() { mTimer = mTimer - Time.deltaTime; if (mTimer < 0) { mTimer = 0.1f; if (libcsv != null) { Byte[] videoData = LibCSV.GetCurrentVideoData(); if (txt2dtest != null && videoData != null) { if (videoData.Length == txt2dtest.width * txt2dtest.height * 4) { txt2dtest.LoadRawTextureData(videoData); txt2dtest.Apply(); LibCSV.SetWrite(); } } } } }