Example #1
0
    public override void OnInspectorGUI()
    {
        GUI.enabled = false;
        EditorGUILayout.PropertyField(script, true, new GUILayoutOption[0]);
        GUI.enabled = true;

#if UNITY_WEBPLAYER || UNITY_WEBGL
        EditorGUILayout.HelpBox("This component does not work on web player/webGL platform", MessageType.Error);
#else
        this.serializedObject.Update();

        DeviceCamera deviceCamera = (DeviceCamera)target;

        EditorGUILayout.PropertyField(defaultDevice, new GUIContent("default Device"));
        EditorGUILayout.PropertyField(capWidth, new GUIContent("capture Width"));
        EditorGUILayout.PropertyField(capHeight, new GUIContent("capture Height"));
        EditorGUILayout.PropertyField(capFPS, new GUIContent("capture FPS"));
        EditorGUILayout.PropertyField(autoPlay, new GUIContent("auto Play"));
        EditorGUILayout.PropertyField(material, new GUIContent("Render Material"));
        EditorGUILayout.PropertyField(rawImage, new GUIContent("Render RawImage"));

        if (Application.isPlaying == true)
        {
            EditorGUILayout.LabelField(string.Format("Device Name: {0}", deviceCamera.deviceName));
            EditorGUILayout.LabelField(string.Format("Image Width: {0:d}", deviceCamera.Width));
            EditorGUILayout.LabelField(string.Format("Image Height: {0:d}", deviceCamera.Height));
            if (GUILayout.Button("Refresh Settings") == true)
            {
                deviceCamera.RefreshSettings();
            }
            if (GUILayout.Button("Change Device") == true)
            {
                deviceCamera.ChangeDevice();
            }
            if (deviceCamera.isPlaying == false)
            {
                if (GUILayout.Button("Play") == true)
                {
                    deviceCamera.Play();
                }
            }
            else
            {
                if (GUILayout.Button("Pause") == true)
                {
                    deviceCamera.Pause();
                }
            }
            if (GUILayout.Button("Stop") == true)
            {
                deviceCamera.Stop();
            }
        }

        this.serializedObject.ApplyModifiedProperties();
#endif
    }