public override void OnInspectorGUI() { //update the object with the object variables serializedObject.Update(); //set the clip var as the target of this inspector Depthkit_Clip clip = (Depthkit_Clip)target; // DK INFO OnInspectorGUI_DepthKitInfo(); EditorGUILayout.BeginVertical("Box"); { // PLAYER INFO OnInspectorGUI_PlayerSettings(clip); // META INFO OnInspectorGUI_PlayerMetaInfo(); EditorGUILayout.Space(); // PLAYER SETUP FEEDBACK OnInspectorGUI_PlayerSetupInfo(clip); } EditorGUILayout.EndVertical(); // RENDERER OPTIONS OnInspectorGUI_CleanupFilters(); EditorGUILayout.Space(); OnInspectorGUI_CheckForUndo(); // APPLY PROPERTY MODIFICATIONS serializedObject.ApplyModifiedProperties(); }
// https://answers.unity.com/questions/413101/invalidoperationexception-operation-is-not-valid-d.html void OnInspectorGui_UserConfirmRendererSwitch() { if (_renderTypeProp.enumValueIndex != cachedRenderType) { Depthkit_Clip clip = (Depthkit_Clip)target; if (cachedRenderType != (int)RenderType.Photo) { if (EditorUtility.DisplayDialog("Changing Renderer type", "WARNING: you will lose all render layers if you change renderer type, would you like to change renderer?", "Yes", "No")) { cachedRenderType = _renderTypeProp.enumValueIndex; clip._needToResetRenderType = true; } else { clip._renderType = (RenderType)cachedRenderType; } } else { cachedRenderType = _renderTypeProp.enumValueIndex; clip._needToResetRenderType = true; } } }
public void _After() { player = null; depthkitClip = null; UnityEngine.GameObject.DestroyImmediate(camObj); UnityEngine.GameObject.DestroyImmediate(depthkitObj); UnityEngine.GameObject.DestroyImmediate(playerObj); }
void OnInspectorGUI_PlayerSettings(Depthkit_Clip clip) { EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_playerTypeProp, new GUIContent("Video Player")); if (EditorGUI.EndChangeCheck() || (_playerTypeProp.enumValueIndex != cachedPlayerType)) { _resetPlayerTypeProp.boolValue = true; cachedPlayerType = _playerTypeProp.enumValueIndex; } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_renderTypeProp, new GUIContent("Look")); if (EditorGUI.EndChangeCheck()) { EditorApplication.delayCall += OnInspectorGui_UserConfirmRendererSwitch; } }
public void _Before() { // Camera setup camObj = new GameObject("Camera"); camObj.AddComponent <Camera>(); camObj.transform.Translate(0, 0, -3); // Player Setup playerObj = new GameObject("Video Player"); player = playerObj.AddComponent <VimeoPlayer>(); player.selectedResolution = StreamingResolution.x360p; player.videoPlayerType = VideoPlayerType.Depthkit; player.autoPlay = false; //Depthkit setup depthkitObj = new GameObject("Depthkit Clip"); depthkitClip = depthkitObj.AddComponent <Depthkit.Depthkit_Clip>(); depthkitClip.Setup(Depthkit.AvailablePlayerType.UnityVideoPlayer, Depthkit.RenderType.Photo, new TextAsset()); player.depthKitClip = depthkitClip; triggered = false; }
void OnInspectorGUI_PlayerSetupInfo(Depthkit_Clip clip) { if (clip.IsSetup) { GUI.backgroundColor = Color.green; EditorGUILayout.BeginVertical(); EditorGUILayout.HelpBox("Depthkit clip is setup and ready for playback", MessageType.Info); } else { GUI.backgroundColor = Color.red; EditorGUILayout.BeginVertical(); EditorGUILayout.HelpBox("Depthkit clip is not setup. \n" + string.Format("Player Setup: {0} | Metadata Setup: + {1} | Renderer Setup: {2}", clip.PlayerSetup, clip.MetaSetup, clip.RendererSetup), MessageType.Error); } EditorGUILayout.EndVertical(); GUI.backgroundColor = Color.white; }