Created
May 16, 2015 03:42
-
-
Save grimmdev/7c15295edf9adf3cdb14 to your computer and use it in GitHub Desktop.
Small Texture Utility for some texture functions in Unity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class TextureTest : MonoBehaviour { | |
public Renderer rend; | |
// Use this for initialization | |
private void Awake () { | |
rend.material.mainTexture = TextureUtility.CamToText (); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System; | |
using System.Collections; | |
public class TextureUtility { | |
// Let's convert or make a texture 2d from a webcam image. | |
public static Texture2D CamToTexture() { | |
WebCamTexture webcamTexture = new WebCamTexture(); | |
webcamTexture.Play(); | |
Texture2D tempText = new Texture2D(webcamTexture.width,webcamTexture.height); | |
IntPtr pointer = webcamTexture.GetNativeTexturePtr(); | |
tempText.UpdateExternalTexture(pointer); | |
return tempText; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment