Skip to content

Commit 2bf4e48

Browse files
Merge pull request #59 from CognitiveVR/develop
1.0.7 Release
2 parents 9e0422a + 93b54cc commit 2bf4e48

19 files changed

+435
-369
lines changed

Editor/DynamicObjectInspector.cs

Lines changed: 79 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public override void OnInspectorGUI()
4949
bool basicGUIChanged = false;
5050
EditorGUI.BeginChangeCheck();
5151

52+
//consider adding an actual property for id source - instead of infering from useCustomId and objectPool references. should simplify property display in inspector
5253
var script = serializedObject.FindProperty("m_Script");
5354
var updateRate = serializedObject.FindProperty("UpdateRate");
5455
var positionThreshold = serializedObject.FindProperty("PositionThreshold");
@@ -119,73 +120,104 @@ public override void OnInspectorGUI()
119120
}
120121
}
121122

123+
int targetIdType = -1;
124+
bool allSelectedShareIdType = true;
125+
122126
//dynamic id sources - custom id, generate at runtime, id pool asset
123-
if (idType == -1)
127+
var primaryDynamic = targets[0] as DynamicObject;
128+
if (primaryDynamic.UseCustomId)
124129
{
125-
var dyn = target as DynamicObject;
126-
if (dyn.UseCustomId) idType = 0;
127-
else if (dyn.IdPool != null) idType = 2;
128-
else idType = 1;
130+
targetIdType = 0;
131+
idType = 0;
129132
}
130-
GUILayout.BeginHorizontal();
131-
idType = EditorGUILayout.Popup(new GUIContent("Id Source"),idType, idTypeNames);
132-
133-
if (idType == 0) //custom id
133+
else if (primaryDynamic.IdPool != null)
134134
{
135-
EditorGUILayout.PropertyField(customId, new GUIContent(""));
136-
useCustomId.boolValue = true;
137-
idPool.objectReferenceValue = null;
135+
targetIdType = 2;
136+
idType = 2;
138137
}
139-
else if (idType == 1) //generate id
138+
else
140139
{
141-
EditorGUI.BeginDisabledGroup(true);
142-
EditorGUILayout.LabelField(new GUIContent("Id will be generated at runtime", "This object will not be included in aggregation metrics on the dashboard"));
143-
EditorGUI.EndDisabledGroup();
144-
customId.stringValue = string.Empty;
145-
useCustomId.boolValue = false;
146-
idPool.objectReferenceValue = null;
140+
targetIdType = 1;
141+
idType = 1;
147142
}
148-
else if (idType == 2) //id pool
143+
144+
//check if all selected objects have the same idtype
145+
foreach (var t in targets)
149146
{
150-
EditorGUILayout.ObjectField(idPool, new GUIContent("", "Provides a consistent list of Ids to be used at runtime. Allows aggregated data from objects spawned at runtime"));
151-
customId.stringValue = string.Empty;
152-
useCustomId.boolValue = false;
147+
var tdyn = (DynamicObject)t;
148+
if (tdyn.UseCustomId) { if (targetIdType != 0) { allSelectedShareIdType = false; break; } }
149+
else if (tdyn.IdPool != null) {if (targetIdType != 2) { allSelectedShareIdType = false; break; } }
150+
else if (targetIdType != 1) { allSelectedShareIdType = false; break; }
153151
}
154-
GUILayout.EndHorizontal();
155152

156-
if (idType == 2) //id pool
153+
//if all id sources from selected objects are the same, display shared property fields
154+
//otherwise display 'multiple values'
155+
if (!allSelectedShareIdType)
156+
{
157+
EditorGUILayout.LabelField("Id Source", "Multiple Values");
158+
}
159+
else
157160
{
158-
var dyn = target as DynamicObject;
159-
if (dyn.IdPool == null)
161+
GUILayout.BeginHorizontal();
162+
idType = EditorGUILayout.Popup(new GUIContent("Id Source"), idType, idTypeNames);
163+
164+
if (idType == 0) //custom id
160165
{
161-
if (GUILayout.Button("New Dynamic Object Id Pool")) //this can overwrite an existing id pool with the same name. should this just find a pool?
162-
{
163-
string poolMeshName = dyn.MeshName;
164-
string assetPath = "Assets/" + poolMeshName + " Id Pool.asset";
166+
EditorGUILayout.PropertyField(customId, new GUIContent(""));
167+
useCustomId.boolValue = true;
168+
idPool.objectReferenceValue = null;
169+
}
170+
else if (idType == 1) //generate id
171+
{
172+
EditorGUI.BeginDisabledGroup(true);
173+
EditorGUILayout.LabelField(new GUIContent("Id will be generated at runtime", "This object will not be included in aggregation metrics on the dashboard"));
174+
EditorGUI.EndDisabledGroup();
175+
customId.stringValue = string.Empty;
176+
useCustomId.boolValue = false;
177+
idPool.objectReferenceValue = null;
178+
}
179+
else if (idType == 2) //id pool
180+
{
181+
EditorGUILayout.ObjectField(idPool, new GUIContent("", "Provides a consistent list of Ids to be used at runtime. Allows aggregated data from objects spawned at runtime"));
182+
customId.stringValue = string.Empty;
183+
useCustomId.boolValue = false;
184+
}
185+
GUILayout.EndHorizontal();
165186

166-
//check if asset exists
167-
var foundPool = (DynamicObjectIdPool)AssetDatabase.LoadAssetAtPath(assetPath, typeof(DynamicObjectIdPool));
168-
if (foundPool == null)
169-
{
170-
var pool = GenerateNewIDPoolAsset(assetPath, dyn);
171-
idPool.objectReferenceValue = pool;
172-
}
173-
else
187+
if (idType == 2) //id pool
188+
{
189+
var dyn = target as DynamicObject;
190+
if (dyn.IdPool == null)
191+
{
192+
if (GUILayout.Button("New Dynamic Object Id Pool")) //this can overwrite an existing id pool with the same name. should this just find a pool?
174193
{
175-
//popup - new pool asset, add to existing pool (if matching mesh name), cancel
176-
int result = EditorUtility.DisplayDialogComplex("Found Id Pool", "An existing Id Pool with the same mesh name was found. Do you want to use this Id Pool instead?", "New Asset", "Cancel", "Use Existing");
194+
string poolMeshName = dyn.MeshName;
195+
string assetPath = "Assets/" + poolMeshName + " Id Pool.asset";
177196

178-
if (result == 0)//new asset with unique name
197+
//check if asset exists
198+
var foundPool = (DynamicObjectIdPool)AssetDatabase.LoadAssetAtPath(assetPath, typeof(DynamicObjectIdPool));
199+
if (foundPool == null)
179200
{
180-
string finalAssetPath = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(assetPath);
181-
var pool = GenerateNewIDPoolAsset(finalAssetPath, dyn);
201+
var pool = GenerateNewIDPoolAsset(assetPath, dyn);
182202
idPool.objectReferenceValue = pool;
183203
}
184-
if (result == 2) //reference existing pool
204+
else
185205
{
186-
idPool.objectReferenceValue = foundPool;
206+
//popup - new pool asset, add to existing pool (if matching mesh name), cancel
207+
int result = EditorUtility.DisplayDialogComplex("Found Id Pool", "An existing Id Pool with the same mesh name was found. Do you want to use this Id Pool instead?", "New Asset", "Cancel", "Use Existing");
208+
209+
if (result == 0)//new asset with unique name
210+
{
211+
string finalAssetPath = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(assetPath);
212+
var pool = GenerateNewIDPoolAsset(finalAssetPath, dyn);
213+
idPool.objectReferenceValue = pool;
214+
}
215+
if (result == 2) //reference existing pool
216+
{
217+
idPool.objectReferenceValue = foundPool;
218+
}
219+
if (result == 1) { }//cancel
187220
}
188-
if (result == 1) { }//cancel
189221
}
190222
}
191223
}

Editor/ExportUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static void PostSceneUploadResponse(int responseCode, string error, string text)
400400
AssetDatabase.SaveAssets();
401401
}
402402

403-
UploadSceneSettings.LastRevision = System.DateTime.UtcNow.ToBinary();
403+
UploadSceneSettings.LastRevision = System.DateTime.UtcNow.ToString(System.Globalization.CultureInfo.InvariantCulture);
404404
GUI.FocusControl("NULL");
405405
EditorUtility.SetDirty(Cognitive3D_Preferences.Instance);
406406
AssetDatabase.SaveAssets();

Editor/InitWizard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public SDKDefine(string name, string define, string tooltip="")
277277
new SDKDefine("SRanipal Runtime","C3D_SRANIPAL","Adds Eyetracking for the Vive Pro Eye" ), //previously C3D_VIVEPROEYE
278278
new SDKDefine("Varjo XR 3.0.0","C3D_VARJOXR", "Adds Eye Tracking for Varjo Headsets"),
279279
new SDKDefine("Vive Wave 5.0.2","C3D_VIVEWAVE", "Adds Eye Tracking for Focus 3" ),
280-
new SDKDefine("Pico Unity XR Platform 1.2.3","C3D_PICOXR", "Adds Eye Tracking for Pico Neo 3 Eye" ),
280+
new SDKDefine("Pico Unity XR Platform 2.1.3","C3D_PICOXR", "Adds Eye Tracking for Pico Neo 3 Eye" ),
281281
new SDKDefine("MRTK 2.5.4","C3D_MRTK", "Adds Eye Tracking for Hololens 2" ),
282282
new SDKDefine("Windows Mixed Reality XR","C3D_WINDOWSMR", "Deprecated. Select 'Default'" ), //legacy
283283
new SDKDefine("Varjo VR","C3D_VARJOVR", "Prefer to upgrade to Varjo XR instead" ), //legacy

Editor/Setup360Window.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Cognitive3D
1111
public class Setup360Window : EditorWindow
1212
{
1313
UnityEngine.Video.VideoClip selectedClip;
14+
UnityEngine.Camera userCamera;
1415
bool latlong = true;
1516

1617
public static void Init()
@@ -35,7 +36,8 @@ void OnGUI()
3536
}
3637
GUILayout.FlexibleSpace();
3738
GUILayout.EndHorizontal();
38-
selectedClip = (UnityEngine.Video.VideoClip)EditorGUILayout.ObjectField(selectedClip, typeof(UnityEngine.Video.VideoClip), true);
39+
selectedClip = (UnityEngine.Video.VideoClip)EditorGUILayout.ObjectField("Video Clip", selectedClip, typeof(UnityEngine.Video.VideoClip), true);
40+
userCamera = (UnityEngine.Camera)EditorGUILayout.ObjectField("Main Camera", userCamera, typeof(UnityEngine.Camera), true);
3941

4042
if (EditorCore.MediaSources.Length == 0)
4143
{
@@ -73,7 +75,7 @@ void OnGUI()
7375
GUILayout.EndHorizontal();
7476

7577

76-
EditorGUI.BeginDisabledGroup(selectedClip == null || string.IsNullOrEmpty(EditorCore.MediaSources[_choiceIndex].name));
78+
EditorGUI.BeginDisabledGroup(selectedClip == null || string.IsNullOrEmpty(EditorCore.MediaSources[_choiceIndex].name) || userCamera == null);
7779
if (GUILayout.Button("Create"))
7880
{
7981
CreateAssets();
@@ -133,6 +135,9 @@ void CreateAssets()
133135
sphere = (GameObject)PrefabUtility.InstantiatePrefab(Resources.Load("invertedspherecube"));
134136
}
135137
sphere.gameObject.name = "360 Video Player";
138+
sphere.transform.position = userCamera.transform.position;
139+
Cognitive3D.Components.GazeSphere360 myGaze = sphere.AddComponent<Cognitive3D.Components.GazeSphere360>();
140+
myGaze.UserCamera = userCamera;
136141

137142
//setup video source to write to render texture
138143
var vp = sphere.GetComponentInChildren<UnityEngine.Video.VideoPlayer>();
@@ -172,20 +177,6 @@ void CreateAssets()
172177
internalGo.AddComponent<DynamicObject>();
173178
}
174179

175-
//find the main camera and move it to the origin
176-
var camMain = Camera.main;
177-
if (camMain == null)
178-
{
179-
Debug.LogError("Cognitive3D 360 Setup: Could not find Camera.Main! Creating a new camera");
180-
var cameraGo = new GameObject("Main Camera");
181-
cameraGo.tag = "MainCamera";
182-
cameraGo.AddComponent<Camera>();
183-
}
184-
else
185-
{
186-
camMain.transform.position = Vector3.zero;
187-
}
188-
189180
UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
190181
Selection.activeGameObject = internalGo;
191182

0 commit comments

Comments
 (0)