OvrvisionTools.cs
3.15 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
using UnityEngine;
using System.Collections;
using UnityEditor;
public class OvrvisionTools : EditorWindow
{
//Create MenuItem
[MenuItem("OvrvisionPro/Add OvrvisionProCamera", false, 10)]
static void AddOvrvisionProCamera()
{
if (GameObject.Find("OvrvisionProCamera") == null)
{
//Eliminate other camera objects.
Camera[] camObjs = GameObject.FindObjectsOfType(typeof(Camera)) as Camera[];
foreach (Camera camobj in camObjs)
{
string delName = camobj.gameObject.name;
if (UnityEditor.EditorUtility.DisplayDialog(delName + " : Competition!", "Do you inactivate the unnecessary camera[" + delName + "] object which will cause the problem?", "YES", "NO"))
{
camobj.gameObject.SetActive(false);
}
}
CreateLayer(24, "OvrvisionProLeftImage");
CreateLayer(25, "OvrvisionProRightImage");
Object obj = Instantiate(Resources.Load("Prefabs/OvrvisionProCamera"), new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
obj.name = "OvrvisionProCamera";
//Force Virtual mode.
PlayerSettings.virtualRealitySupported = true;
}
else
{
UnityEditor.EditorUtility.DisplayDialog("Error!", "The add failed. [OvrvisionProCamera] object already exists in this scene.", "OK");
}
}
[MenuItem("OvrvisionPro/Add OvrvisionARTracker", false, 30)]
static void AddOvrvisionARTracker()
{
if (GameObject.Find("OvrvisionTracker") == null)
{
Object obj = Instantiate(Resources.Load("Prefabs/OvrvisionTracker"), new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
obj.name = "OvrvisionTracker";
}
else
{
UnityEditor.EditorUtility.DisplayDialog("Error!", "The add failed. [OvrvisionTracker] object already exists in this scene.", "OK");
}
}
[MenuItem("OvrvisionPro/Add OvrvisionHandTracker", false, 40)]
static void AddOvrvisionHandTracker()
{
if (GameObject.Find("OvrvisionHandTracker") == null)
{
Object obj = Instantiate(Resources.Load("Prefabs/OvrvisionHandTracker"), new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
obj.name = "OvrvisionHandTracker";
}
else
{
UnityEditor.EditorUtility.DisplayDialog("Error!", "The add failed. [OvrvisionHandTracker] object already exists in this scene.", "OK");
}
}
[MenuItem("OvrvisionPro/Add ShadowPlane for Ovrvision", false, 60)]
static void AddShadowPlane_for_Ovrvision()
{
}
//Create Layer
static void CreateLayer(int num, string layerName)
{
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
SerializedProperty layers = tagManager.FindProperty("layers");
if (layers == null || !layers.isArray)
{
Debug.LogWarning("Can not set up the layers. It is possible the format of the layers and tags data has changed in this version of Unity.");
Debug.LogWarning("Layers is null: " + (layers == null));
return;
}
SerializedProperty layerSP = layers.GetArrayElementAtIndex(num);
if (layerSP.stringValue == "")
{
layerSP.stringValue = layerName;
tagManager.ApplyModifiedProperties();
}
else if (layerSP.stringValue != layerName)
{
UnityEditor.EditorUtility.DisplayDialog("Error!", "The layer is competing with others. Please confirm layer information. ", "OK");
}
}
}