Mercurial > hg > Game > Games
comparison Orchestland/Assets/LeapMotion/Scripts/LeapImageBasedMaterial.cs @ 1:f7675884f2a1
Add Orchestland project
author | Daiki OYAKAWA <e135764@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2015 23:09:20 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:347d21cdfc22 | 1:f7675884f2a1 |
---|---|
1 using UnityEngine; | |
2 using System.Collections; | |
3 using System.Collections.Generic; | |
4 | |
5 public class LeapImageBasedMaterial : MonoBehaviour { | |
6 public ImageMode imageMode = ImageMode.STEREO; | |
7 | |
8 public enum ImageMode { | |
9 STEREO, | |
10 LEFT_ONLY, | |
11 RIGHT_ONLY | |
12 } | |
13 | |
14 void Awake() { | |
15 if (FindObjectOfType<LeapImageRetriever>() == null) { | |
16 Debug.LogWarning("Place a LeapImageRetriever script on a camera to enable Leap image-based materials"); | |
17 enabled = false; | |
18 } | |
19 } | |
20 | |
21 void OnEnable() { | |
22 LeapImageRetriever.registerImageBasedMaterial(this); | |
23 // Make shader consistent with settings | |
24 | |
25 if (QualitySettings.activeColorSpace == ColorSpace.Linear) { | |
26 GetComponent<Renderer> ().material.SetFloat ("_ColorSpaceGamma", 1.0f); | |
27 } else { | |
28 float gamma = -Mathf.Log10(Mathf.GammaToLinearSpace(0.1f)); | |
29 GetComponent<Renderer> ().material.SetFloat ("_ColorSpaceGamma", gamma); | |
30 //Debug.Log ("Derived gamma = " + gamma); | |
31 } | |
32 } | |
33 | |
34 void OnDisable() { | |
35 LeapImageRetriever.unregisterImageBasedMaterial(this); | |
36 } | |
37 } |