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 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(); }