OvrvisionEditor.cs
5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;
/// <summary>
/// Ovrvision Custom Editor
/// </summary>
[CustomEditor( typeof(Ovrvision) )]
public class OvrvisionEditor : Editor {
private const int OV_SET_AUTOMODE = (-1);
public override void OnInspectorGUI() {
Ovrvision obj = target as Ovrvision;
string[] cammode = { "2560x1920@15", "1920x1080@30", "1280x960@45", "960x950@60:Default", "1280x800@60", "640x480@90", "320x240@120" };
EditorGUILayout.LabelField( "Ovrvision Status" );
if (obj.CameraStatus())
{
string text = "Opened : ";
text += cammode[obj.cameraMode];
EditorGUILayout.HelpBox(text, MessageType.Info, true);
}
else
{
obj.cameraMode = EditorGUILayout.Popup("Camera Mode", obj.cameraMode, cammode);
EditorGUILayout.HelpBox("Closed", MessageType.Error, true);
}
EditorGUILayout.Space();
obj.overlaySettings = EditorGUILayout.Toggle("Overlay Ovrvision settings", obj.overlaySettings);
if (obj.overlaySettings)
{
obj.conf_exposure = EditorGUILayout.IntSlider("Exposure", obj.conf_exposure, 0, 32767);
obj.conf_gain = EditorGUILayout.IntSlider("Gain", obj.conf_gain, 1, 47);
obj.conf_blc = EditorGUILayout.IntSlider("BLC", obj.conf_blc, 0, 1023);
obj.conf_wb_auto = EditorGUILayout.Toggle("WhiteBalance Auto", obj.conf_wb_auto);
if (!obj.conf_wb_auto) {
obj.conf_wb_r = EditorGUILayout.IntSlider("WhiteBalance R", obj.conf_wb_r, 0, 4095);
obj.conf_wb_g = EditorGUILayout.IntSlider("WhiteBalance G", obj.conf_wb_g, 0, 4095);
obj.conf_wb_b = EditorGUILayout.IntSlider("WhiteBalance B", obj.conf_wb_b, 0, 4095);
}
if (GUILayout.Button("Default config", GUILayout.Width(200)))
{
obj.conf_exposure = 12960;
obj.conf_gain = 8;
obj.conf_blc = 32;
obj.conf_wb_r = 1474;
obj.conf_wb_g = 1024;
obj.conf_wb_b = 1738;
obj.conf_wb_auto = true;
}
}
EditorGUILayout.Space();
//Ovrvision AR
obj.useOvrvisionAR = EditorGUILayout.Toggle("Use the OvrvisionAR", obj.useOvrvisionAR);
obj.ARsize = EditorGUILayout.FloatField("AR Marker size(meter)", obj.ARsize);
EditorGUILayout.Space();
obj.useOvrvisionTrack = EditorGUILayout.Toggle("Use the OvrvisionTrack", obj.useOvrvisionTrack);
EditorGUILayout.Space();
string[] planeshader = { "Normal Shader", "Chroma-key Shader", "Hand Mask Shader", "None" };
obj.camViewShader = EditorGUILayout.Popup("Camera Overlay", obj.camViewShader, planeshader);
if (obj.camViewShader == 1)
{ //Chroma-Key
obj.chroma_hue.x = EditorGUILayout.Slider("Max Hue", obj.chroma_hue.x, 0.0f, 1.0f);
obj.chroma_hue.y = EditorGUILayout.Slider("Min Hue", obj.chroma_hue.y, 0.0f, 1.0f);
obj.chroma_saturation.x = EditorGUILayout.Slider("Max Saturation", obj.chroma_saturation.x, 0.0f, 1.0f);
obj.chroma_saturation.y = EditorGUILayout.Slider("Min Saturation", obj.chroma_saturation.y, 0.0f, 1.0f);
obj.chroma_brightness.x = EditorGUILayout.Slider("Max Brightness", obj.chroma_brightness.x, 0.0f, 1.0f);
obj.chroma_brightness.y = EditorGUILayout.Slider("Min Brightness ", obj.chroma_brightness.y, 0.0f, 1.0f);
} else if (obj.camViewShader == 2)
{ //Hand Mask
obj.chroma_hue.x = EditorGUILayout.Slider("Max Hue", obj.chroma_hue.x, 0.0f, 1.0f);
obj.chroma_hue.y = EditorGUILayout.Slider("Min Hue", obj.chroma_hue.y, 0.0f, 1.0f);
obj.chroma_saturation.x = EditorGUILayout.Slider("Max Saturation", obj.chroma_saturation.x, 0.0f, 1.0f);
obj.chroma_saturation.y = EditorGUILayout.Slider("Min Saturation", obj.chroma_saturation.y, 0.0f, 1.0f);
obj.chroma_brightness.x = EditorGUILayout.Slider("Max Brightness", obj.chroma_brightness.x, 0.0f, 1.0f);
obj.chroma_brightness.y = EditorGUILayout.Slider("Min Brightness ", obj.chroma_brightness.y, 0.0f, 1.0f);
obj.chroma_y.x = EditorGUILayout.Slider("Max Y", obj.chroma_y.x, 0.0f, 1.0f);
obj.chroma_y.y = EditorGUILayout.Slider("Min Y", obj.chroma_y.y, 0.0f, 1.0f);
obj.chroma_cb.x = EditorGUILayout.Slider("Max Cb", obj.chroma_cb.x, 0.0f, 1.0f);
obj.chroma_cb.y = EditorGUILayout.Slider("Min Cb", obj.chroma_cb.y, 0.0f, 1.0f);
obj.chroma_cr.x = EditorGUILayout.Slider("Max Cr", obj.chroma_cr.x, 0.0f, 1.0f);
obj.chroma_cr.y = EditorGUILayout.Slider("Min Cr ", obj.chroma_cr.y, 0.0f, 1.0f);
}
//changed param
if (GUI.changed) {
obj.UpdateOvrvisionSetting();
}
EditorUtility.SetDirty( target ); //editor set
}
/* not use
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
// Copy of "arcl" files
string sourceFile = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "arcl");
string targetFile = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), "arcl");
CopyDirectory(sourceFile, targetFile);
}
public static void CopyDirectory(string stSourcePath, string stDestPath)
{
if (!System.IO.Directory.Exists(stDestPath))
{
System.IO.Directory.CreateDirectory(stDestPath);
System.IO.File.SetAttributes(stDestPath, System.IO.File.GetAttributes(stSourcePath));
}
foreach (string stCopyFrom in System.IO.Directory.GetFiles(stSourcePath))
{
string stCopyTo = System.IO.Path.Combine(stDestPath, System.IO.Path.GetFileName(stCopyFrom));
System.IO.File.Copy(stCopyFrom, stCopyTo, true);
}
foreach (string stCopyFrom in System.IO.Directory.GetDirectories(stSourcePath))
{
string stCopyTo = System.IO.Path.Combine(stDestPath, System.IO.Path.GetFileName(stCopyFrom));
CopyDirectory(stCopyFrom, stCopyTo);
}
}
*/
}