private static List <string> GetMaterialPropertyNames(UnityEngine.Object obj, bool multiSelect, out int selection, out bool invalidSelection) { selection = -1; invalidSelection = true; List <string> list = new List <string>(); VideoPlayer videoPlayer = obj as VideoPlayer; List <string> result; if (!videoPlayer) { result = list; } else { Renderer targetRenderer = VideoPlayerEditor.GetTargetRenderer(videoPlayer); if (!targetRenderer) { result = list; } else { Material[] sharedMaterials = targetRenderer.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { Material material = sharedMaterials[i]; if (material) { int j = 0; int propertyCount = ShaderUtil.GetPropertyCount(material.shader); while (j < propertyCount) { if (ShaderUtil.GetPropertyType(material.shader, j) == ShaderUtil.ShaderPropertyType.TexEnv) { string propertyName = ShaderUtil.GetPropertyName(material.shader, j); if (!list.Contains(propertyName)) { list.Add(propertyName); } } j++; } selection = list.IndexOf(videoPlayer.targetMaterialProperty); invalidSelection = (selection < 0 && list.Count <string>() > 0); if (invalidSelection && !multiSelect) { selection = list.Count <string>(); list.Add(videoPlayer.targetMaterialProperty); } } } result = list; } } return(result); }
private void OnEnable() { this.m_ShowRenderTexture.valueChanged.AddListener(new UnityAction(base.Repaint)); this.m_ShowTargetCamera.valueChanged.AddListener(new UnityAction(base.Repaint)); this.m_ShowRenderer.valueChanged.AddListener(new UnityAction(base.Repaint)); this.m_ShowMaterialProperty.valueChanged.AddListener(new UnityAction(base.Repaint)); this.m_DataSourceIsClip.valueChanged.AddListener(new UnityAction(base.Repaint)); this.m_ShowAspectRatio.valueChanged.AddListener(new UnityAction(base.Repaint)); this.m_ShowAudioControls.valueChanged.AddListener(new UnityAction(base.Repaint)); this.m_DataSource = base.serializedObject.FindProperty("m_DataSource"); this.m_VideoClip = base.serializedObject.FindProperty("m_VideoClip"); this.m_Url = base.serializedObject.FindProperty("m_Url"); this.m_PlayOnAwake = base.serializedObject.FindProperty("m_PlayOnAwake"); this.m_WaitForFirstFrame = base.serializedObject.FindProperty("m_WaitForFirstFrame"); this.m_Looping = base.serializedObject.FindProperty("m_Looping"); this.m_PlaybackSpeed = base.serializedObject.FindProperty("m_PlaybackSpeed"); this.m_RenderMode = base.serializedObject.FindProperty("m_RenderMode"); this.m_TargetTexture = base.serializedObject.FindProperty("m_TargetTexture"); this.m_TargetCamera = base.serializedObject.FindProperty("m_TargetCamera"); this.m_TargetMaterialRenderer = base.serializedObject.FindProperty("m_TargetMaterialRenderer"); this.m_TargetMaterialProperty = base.serializedObject.FindProperty("m_TargetMaterialProperty"); this.m_AspectRatio = base.serializedObject.FindProperty("m_AspectRatio"); this.m_TargetCameraAlpha = base.serializedObject.FindProperty("m_TargetCameraAlpha"); this.m_TargetCamera3DLayout = base.serializedObject.FindProperty("m_TargetCamera3DLayout"); this.m_AudioOutputMode = base.serializedObject.FindProperty("m_AudioOutputMode"); this.m_ControlledAudioTrackCount = base.serializedObject.FindProperty("m_ControlledAudioTrackCount"); this.m_EnabledAudioTracks = base.serializedObject.FindProperty("m_EnabledAudioTracks"); this.m_TargetAudioSources = base.serializedObject.FindProperty("m_TargetAudioSources"); this.m_DirectAudioVolumes = base.serializedObject.FindProperty("m_DirectAudioVolumes"); this.m_DirectAudioMutes = base.serializedObject.FindProperty("m_DirectAudioMutes"); this.m_ShowRenderTexture.value = (this.m_RenderMode.intValue == 2); this.m_ShowTargetCamera.value = (this.m_RenderMode.intValue == 0 || this.m_RenderMode.intValue == 1); this.m_ShowRenderer.value = (this.m_RenderMode.intValue == 3); UnityEngine.Object[] arg_321_0 = base.targets; if (VideoPlayerEditor.< > f__mg$cache0 == null) { VideoPlayerEditor.< > f__mg$cache0 = new VideoPlayerEditor.EntryGenerator(VideoPlayerEditor.GetMaterialPropertyNames); } this.m_MaterialPropertyPopupContent = VideoPlayerEditor.BuildPopupEntries(arg_321_0, VideoPlayerEditor.< > f__mg$cache0, out this.m_MaterialPropertyPopupSelection, out this.m_MaterialPropertyPopupInvalidSelections); this.m_MaterialPropertyPopupContentHash = VideoPlayerEditor.GetMaterialPropertyPopupHash(base.targets); this.m_ShowMaterialProperty.value = (base.targets.Count <UnityEngine.Object>() > 1 || (this.m_MaterialPropertyPopupSelection >= 0 && this.m_MaterialPropertyPopupContent.Length > 0)); this.m_DataSourceIsClip.value = (this.m_DataSource.intValue == 0); this.m_ShowAspectRatio.value = (this.m_RenderMode.intValue != 3 && this.m_RenderMode.intValue != 4); this.m_ShowAudioControls.value = (this.m_AudioOutputMode.intValue != 0); VideoPlayer videoPlayer = base.target as VideoPlayer; videoPlayer.prepareCompleted += new VideoPlayer.EventHandler(this.PrepareCompleted); this.m_AudioTrackInfos = new List <VideoPlayerEditor.AudioTrackInfo>(); }
private static int GetMaterialPropertyPopupHash(UnityEngine.Object[] objects) { int num = 0; for (int i = 0; i < objects.Length; i++) { VideoPlayer videoPlayer = (VideoPlayer)objects[i]; if (videoPlayer) { Renderer targetRenderer = VideoPlayerEditor.GetTargetRenderer(videoPlayer); if (targetRenderer) { num ^= videoPlayer.targetMaterialProperty.GetHashCode(); Material[] sharedMaterials = targetRenderer.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { Material material = sharedMaterials[j]; if (material) { num ^= material.name.GetHashCode(); int k = 0; int propertyCount = ShaderUtil.GetPropertyCount(material.shader); while (k < propertyCount) { if (ShaderUtil.GetPropertyType(material.shader, k) == ShaderUtil.ShaderPropertyType.TexEnv) { num ^= ShaderUtil.GetPropertyName(material.shader, k).GetHashCode(); } k++; } } } } } } return(num); }
private string GenerateMultiMaterialinformation() { string result; if (base.targets.Count <UnityEngine.Object>() > 1) { result = ""; } else { VideoPlayer videoPlayer = base.target as VideoPlayer; if (!videoPlayer) { result = ""; } else { Renderer targetRenderer = VideoPlayerEditor.GetTargetRenderer(videoPlayer); if (!targetRenderer) { result = ""; } else { Material[] sharedMaterials = targetRenderer.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Count <Material>() <= 1) { result = ""; } else { List <string> list = new List <string>(); Material[] array = sharedMaterials; for (int i = 0; i < array.Length; i++) { Material material = array[i]; if (material) { int j = 0; int propertyCount = ShaderUtil.GetPropertyCount(material.shader); while (j < propertyCount) { if (ShaderUtil.GetPropertyType(material.shader, j) == ShaderUtil.ShaderPropertyType.TexEnv && ShaderUtil.GetPropertyName(material.shader, j) == this.m_TargetMaterialProperty.stringValue) { list.Add(material.name); break; } j++; } } } if (list.Count <string>() == sharedMaterials.Count <Material>()) { result = VideoPlayerEditor.s_Styles.texPropInAllMaterialsHelp; } else { result = string.Format(VideoPlayerEditor.s_Styles.texPropInSomeMaterialsHelp, list.Count <string>(), sharedMaterials.Count <Material>()) + ": " + string.Join(", ", list.ToArray()); } } } } } return(result); }
private void HandleTargetField(VideoRenderMode currentRenderMode) { this.m_ShowRenderTexture.target = (currentRenderMode == VideoRenderMode.RenderTexture); if (EditorGUILayout.BeginFadeGroup(this.m_ShowRenderTexture.faded)) { EditorGUILayout.PropertyField(this.m_TargetTexture, VideoPlayerEditor.s_Styles.textureContent, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); this.m_ShowTargetCamera.target = (currentRenderMode == VideoRenderMode.CameraFarPlane || currentRenderMode == VideoRenderMode.CameraNearPlane); if (EditorGUILayout.BeginFadeGroup(this.m_ShowTargetCamera.faded)) { EditorGUILayout.PropertyField(this.m_TargetCamera, VideoPlayerEditor.s_Styles.cameraContent, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_TargetCameraAlpha, 0f, 1f, VideoPlayerEditor.s_Styles.alphaContent, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); this.m_ShowRenderer.target = (currentRenderMode == VideoRenderMode.MaterialOverride); if (EditorGUILayout.BeginFadeGroup(this.m_ShowRenderer.faded)) { bool flag = base.targets.Count <UnityEngine.Object>() > 1; if (flag) { EditorGUILayout.PropertyField(this.m_TargetMaterialRenderer, VideoPlayerEditor.s_Styles.materialRendererContent, new GUILayoutOption[0]); } else { Rect controlRect = EditorGUILayout.GetControlRect(true, 16f, new GUILayoutOption[0]); GUIContent label = EditorGUI.BeginProperty(controlRect, VideoPlayerEditor.s_Styles.materialRendererContent, this.m_TargetMaterialRenderer); EditorGUI.BeginChangeCheck(); UnityEngine.Object objectReferenceValue = EditorGUI.ObjectField(controlRect, label, VideoPlayerEditor.GetTargetRenderer((VideoPlayer)base.target), typeof(Renderer), true); if (EditorGUI.EndChangeCheck()) { this.m_TargetMaterialRenderer.objectReferenceValue = objectReferenceValue; } EditorGUI.EndProperty(); } int materialPropertyPopupHash = VideoPlayerEditor.GetMaterialPropertyPopupHash(base.targets); if (this.m_MaterialPropertyPopupContentHash != materialPropertyPopupHash) { UnityEngine.Object[] arg_1CE_0 = base.targets; if (VideoPlayerEditor.< > f__mg$cache1 == null) { VideoPlayerEditor.< > f__mg$cache1 = new VideoPlayerEditor.EntryGenerator(VideoPlayerEditor.GetMaterialPropertyNames); } this.m_MaterialPropertyPopupContent = VideoPlayerEditor.BuildPopupEntries(arg_1CE_0, VideoPlayerEditor.< > f__mg$cache1, out this.m_MaterialPropertyPopupSelection, out this.m_MaterialPropertyPopupInvalidSelections); } VideoPlayerEditor.HandlePopup(VideoPlayerEditor.s_Styles.materialPropertyContent, this.m_TargetMaterialProperty, this.m_MaterialPropertyPopupContent, this.m_MaterialPropertyPopupSelection); if (this.m_MaterialPropertyPopupInvalidSelections > 0 || this.m_MaterialPropertyPopupContent.Length == 0) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(EditorGUIUtility.labelWidth); if (this.m_MaterialPropertyPopupContent.Length == 0) { if (!flag) { EditorGUILayout.HelpBox(VideoPlayerEditor.s_Styles.rendererMaterialsHaveNoTexPropsHelp, MessageType.Warning); } else { EditorGUILayout.HelpBox(VideoPlayerEditor.s_Styles.someRendererMaterialsHaveNoTexPropsHelp, MessageType.Warning); } } else if (!flag) { EditorGUILayout.HelpBox(VideoPlayerEditor.s_Styles.invalidTexPropSelectionHelp, MessageType.Warning); } else if (this.m_MaterialPropertyPopupInvalidSelections == 1) { EditorGUILayout.HelpBox(VideoPlayerEditor.s_Styles.oneInvalidTexPropSelectionHelp, MessageType.Warning); } else { EditorGUILayout.HelpBox(string.Format(VideoPlayerEditor.s_Styles.someInvalidTexPropSelectionsHelp, this.m_MaterialPropertyPopupInvalidSelections), MessageType.Warning); } GUILayout.EndHorizontal(); } else { this.DisplayMultiMaterialInformation(this.m_MaterialPropertyPopupContentHash != materialPropertyPopupHash); } this.m_MaterialPropertyPopupContentHash = materialPropertyPopupHash; } EditorGUILayout.EndFadeGroup(); this.m_ShowAspectRatio.target = (currentRenderMode != VideoRenderMode.MaterialOverride && currentRenderMode != VideoRenderMode.APIOnly); if (EditorGUILayout.BeginFadeGroup(this.m_ShowAspectRatio.faded)) { EditorGUILayout.PropertyField(this.m_AspectRatio, VideoPlayerEditor.s_Styles.aspectRatioLabel, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); }