Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            var reload = false;

            serializedObject.Update();

            // Source infomation
            if (!_filePath.hasMultipleDifferentValues &&
                !_pathMode.hasMultipleDifferentValues &&
                !string.IsNullOrEmpty(_filePath.stringValue))
            {
                ShowSourceInfo((HapPlayer)target);
            }

            // Source file
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedTextField(_filePath);
            EditorGUILayout.PropertyField(_pathMode);
            reload = EditorGUI.EndChangeCheck();

            // Playback control
            EditorGUILayout.PropertyField(_time);
            EditorGUILayout.PropertyField(_speed);
            EditorGUILayout.PropertyField(_loop);

            // Target texture/renderer
            EditorGUILayout.PropertyField(_targetTexture);
            EditorGUILayout.PropertyField(_targetRenderer);

            EditorGUI.indentLevel++;

            if (_targetRenderer.hasMultipleDifferentValues)
            {
                // Multiple renderers selected: Show a simple text field.
                EditorGUILayout.PropertyField(_targetMaterialProperty, Labels.Property);
            }
            else if (_targetRenderer.objectReferenceValue != null)
            {
                // Single renderer: Show the material property selection dropdown.
                MaterialPropertySelector.DropdownList(_targetRenderer, _targetMaterialProperty);
            }

            EditorGUI.indentLevel--;

            serializedObject.ApplyModifiedProperties();

            if (reload)
            {
                // This is a little bit scary hack but we can force a HapPlayer
                // to reload a given video file by invoking OnDestroy.
                foreach (HapPlayer hp in targets)
                {
                    hp.SendMessage("OnDestroy");
                    hp.SendMessage("LateUpdate");
                }

                // Also the source information string should be refreshed.
                _sourceInfo = null;
            }
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (!Application.isPlaying)
            {
                // Source file
                EditorGUILayout.PropertyField(_filePath);
                EditorGUILayout.PropertyField(_pathMode);
            }
            else if (targets.Length == 1)
            {
                EditorGUILayout.HelpBox(SourceInfo, MessageType.None);
            }

            // Playback control
            EditorGUILayout.PropertyField(_time);
            EditorGUILayout.PropertyField(_speed);
            EditorGUILayout.PropertyField(_loop);

            // Target texture/renderer
            EditorGUILayout.PropertyField(_targetTexture);
            EditorGUILayout.PropertyField(_targetRenderer);

            EditorGUI.indentLevel++;

            if (_targetRenderer.hasMultipleDifferentValues)
            {
                // Multiple renderers selected: Show a simple text field.
                EditorGUILayout.PropertyField(_targetMaterialProperty, Labels.Property);
            }
            else if (_targetRenderer.objectReferenceValue != null)
            {
                // Single renderer: Show the material property selection dropdown.
                MaterialPropertySelector.DropdownList(_targetRenderer, _targetMaterialProperty);
            }

            EditorGUI.indentLevel--;

            serializedObject.ApplyModifiedProperties();
        }