private void OnEnable() { if (this.skeletonRenderer == null) { return; } if (this.copiedBlock == null) { this.copiedBlock = new MaterialPropertyBlock(); } this.mainMeshRenderer = this.skeletonRenderer.GetComponent <MeshRenderer>(); this.skeletonRenderer.GenerateMeshOverride -= this.HandleRender; this.skeletonRenderer.GenerateMeshOverride += this.HandleRender; if (this.copyMeshRendererFlags) { LightProbeUsage lightProbeUsage = this.mainMeshRenderer.lightProbeUsage; bool receiveShadows = this.mainMeshRenderer.receiveShadows; for (int i = 0; i < this.partsRenderers.Count; i++) { SkeletonPartsRenderer skeletonPartsRenderer = this.partsRenderers[i]; if (!(skeletonPartsRenderer == null)) { MeshRenderer meshRenderer = skeletonPartsRenderer.MeshRenderer; meshRenderer.lightProbeUsage = lightProbeUsage; meshRenderer.receiveShadows = receiveShadows; } } } }
/// <summary> /// Construct a <see cref="RenderMeshDescription"/> using the given values. /// </summary> public RenderMeshDescription( Mesh mesh, Material material, ShadowCastingMode shadowCastingMode = ShadowCastingMode.Off, bool receiveShadows = false, MotionVectorGenerationMode motionVectorGenerationMode = MotionVectorGenerationMode.Camera, int layer = 0, int subMeshIndex = 0, uint renderingLayerMask = 1, LightProbeUsage lightProbeUsage = LightProbeUsage.Off) { Debug.Assert(material != null, "Must have a non-null Material to create RenderMeshDescription."); Debug.Assert(mesh != null, "Must have a non-null Mesh to create RenderMeshDescription."); var needMotionVectorPass = (motionVectorGenerationMode == MotionVectorGenerationMode.Object) || (motionVectorGenerationMode == MotionVectorGenerationMode.ForceNoMotion); RenderMesh = new RenderMesh { mesh = mesh, material = material, subMesh = subMeshIndex, layer = layer, castShadows = shadowCastingMode, receiveShadows = receiveShadows, needMotionVectorPass = needMotionVectorPass, }; RenderingLayerMask = renderingLayerMask; FlipWinding = false; MotionMode = motionVectorGenerationMode; LightProbeUsage = lightProbeUsage; }
public void From(WorkingObject obj) { Name = obj.Name; m_mesh.From(obj.Mesh); m_materialIds = new List <string>(); m_lightProbeUsage = obj.LightProbeUsage; for (int i = 0; i < obj.Materials.Count; ++i) { m_materialIds.Add(obj.Materials[i].Guid); } }
/// <summary> /// Creates new LOD Level Settings. /// </summary> /// <param name="quality">The LOD level quality.</param> public LODSettings(float quality) { this.quality = quality; this.skinQuality = SkinQuality.Auto; this.receiveShadows = true; this.shadowCasting = ShadowCastingMode.On; this.motionVectors = MotionVectorGenerationMode.Object; this.skinnedMotionVectors = true; this.lightProbeUsage = LightProbeUsage.BlendProbes; this.reflectionProbeUsage = ReflectionProbeUsage.BlendProbes; }
/// <summary> /// Creates new LOD Level Settings. /// </summary> /// <param name="quality">The quality.</param> /// <param name="skinQuality">The skin quality.</param> /// <param name="receiveShadows">If receiving shadows.</param> /// <param name="shadowCasting">The shadow casting mode.</param> /// <param name="motionVectors">The motion vector generation mode.</param> /// <param name="skinnedMotionVectors">If motion vectors are skinned.</param> public LODSettings(float quality, SkinQuality skinQuality, bool receiveShadows, ShadowCastingMode shadowCasting, MotionVectorGenerationMode motionVectors, bool skinnedMotionVectors) { this.quality = quality; this.skinQuality = skinQuality; this.receiveShadows = receiveShadows; this.shadowCasting = shadowCasting; this.motionVectors = motionVectors; this.skinnedMotionVectors = skinnedMotionVectors; this.lightProbeUsage = LightProbeUsage.BlendProbes; this.reflectionProbeUsage = ReflectionProbeUsage.BlendProbes; }
/// <summary> /// Creates new LOD Level Settings. /// </summary> /// <param name="quality">The quality.</param> /// <param name="skinQuality">The skin quality.</param> /// <param name="receiveShadows">If receiving shadows.</param> /// <param name="shadowCasting">The shadow casting mode.</param> public LODSettings(float quality, SkinQuality skinQuality, bool receiveShadows, ShadowCastingMode shadowCasting) { this.quality = quality; this.combineMeshes = true; this.skinQuality = skinQuality; this.receiveShadows = receiveShadows; this.shadowCasting = shadowCasting; this.motionVectors = MotionVectorGenerationMode.Object; this.skinnedMotionVectors = true; this.lightProbeUsage = LightProbeUsage.BlendProbes; this.reflectionProbeUsage = ReflectionProbeUsage.BlendProbes; }
/// <summary> /// Construct a <see cref="RenderMeshDescription"/> using defaults from the given /// <see cref="Renderer"/> and <see cref="Mesh"/> objects. /// </summary> /// <param name="renderer">The renderer object (e.g. a <see cref="MeshRenderer"/>) to get default settings from.</param> /// <param name="mesh">The mesh to use and get default bounds from.</param> /// <param name="sharedMaterials">The list of materials to render the entity with. /// If the list is null or empty, <see cref="Renderer.GetSharedMaterials"/> will be used to obtain the list. /// An explicit list can be supplied if you have already called <see cref="Renderer.GetSharedMaterials"/> previously, /// or if you want to use different materials.</param> /// <param name="subMeshIndex">The sub-mesh of the mesh to use for rendering. The corresponding material index /// from <see cref="sharedMaterials"/> will be used as the material for that sub-mesh.</param> public RenderMeshDescription( Renderer renderer, Mesh mesh, List <Material> sharedMaterials = null, int subMeshIndex = 0) { Debug.Assert(renderer != null, "Must have a non-null Renderer to create RenderMeshDescription."); Debug.Assert(mesh != null, "Must have a non-null Mesh to create RenderMeshDescription."); if (sharedMaterials is null) { sharedMaterials = new List <Material>(capacity: 10); } if (sharedMaterials.Count == 0) { renderer.GetSharedMaterials(sharedMaterials); } Debug.Assert(subMeshIndex >= 0 && subMeshIndex < sharedMaterials.Count, "Sub-mesh index out of bounds, no matching material."); var motionVectorGenerationMode = renderer.motionVectorGenerationMode; var needMotionVectorPass = (motionVectorGenerationMode == MotionVectorGenerationMode.Object) || (motionVectorGenerationMode == MotionVectorGenerationMode.ForceNoMotion); RenderMesh = new RenderMesh { mesh = mesh, material = sharedMaterials[subMeshIndex], subMesh = subMeshIndex, layer = renderer.gameObject.layer, castShadows = renderer.shadowCastingMode, receiveShadows = renderer.receiveShadows, needMotionVectorPass = needMotionVectorPass, }; RenderingLayerMask = renderer.renderingLayerMask; FlipWinding = false; MotionMode = motionVectorGenerationMode; var staticLightingMode = RenderMeshUtility.StaticLightingModeFromRenderer(renderer); var lightProbeUsage = renderer.lightProbeUsage; LightProbeUsage = (staticLightingMode == StaticLightingMode.LightProbes) ? lightProbeUsage : LightProbeUsage.Off; }
/// <summary> /// Creates a new LOD level. /// </summary> /// <param name="screenRelativeTransitionHeight">The screen relative height to use for the transition [0-1].</param> /// <param name="fadeTransitionWidth">The width of the cross-fade transition zone (proportion to the current LOD's whole length) [0-1]. Only used if it's not animated.</param> /// <param name="quality">The quality of this level [0-1].</param> /// <param name="combineMeshes">If all renderers and meshes under this level should be combined into one, where possible.</param> /// <param name="combineSubMeshes">If all sub-meshes should be combined into one, where possible.</param> /// <param name="renderers">The renderers used in this level.</param> public LODLevel(float screenRelativeTransitionHeight, float fadeTransitionWidth, float quality, bool combineMeshes, bool combineSubMeshes, Renderer[] renderers) { this.screenRelativeTransitionHeight = Mathf.Clamp01(screenRelativeTransitionHeight); this.fadeTransitionWidth = fadeTransitionWidth; this.quality = Mathf.Clamp01(quality); this.combineMeshes = combineMeshes; this.combineSubMeshes = combineSubMeshes; this.renderers = renderers; this.skinQuality = SkinQuality.Auto; this.shadowCastingMode = ShadowCastingMode.On; this.receiveShadows = true; this.motionVectorGenerationMode = MotionVectorGenerationMode.Object; this.skinnedMotionVectors = true; this.lightProbeUsage = LightProbeUsage.BlendProbes; this.reflectionProbeUsage = ReflectionProbeUsage.BlendProbes; }
public RendererSerializable(Renderer renderer) : base(renderer) { sortingLayerName = renderer.sortingLayerName; sortingLayerID = renderer.sortingLayerID; sortingOrder = renderer.sortingOrder; lightmapIndex = renderer.lightmapIndex; realtimeLightmapIndex = renderer.realtimeLightmapIndex; lightmapScaleOffset = renderer.lightmapScaleOffset; realtimeLightmapScaleOffset = renderer.realtimeLightmapScaleOffset; reflectionProbeUsage = renderer.reflectionProbeUsage; lightProbeUsage = renderer.lightProbeUsage; enabled = renderer.enabled; materials = renderer.materials?.Select(m => new MaterialSerializable(m)).ToArray(); shadowCastingMode = renderer.shadowCastingMode; receiveShadows = renderer.receiveShadows; motionVectorGenerationMode = renderer.motionVectorGenerationMode; }
internal void DrawSelectedProbes() { if (!ShouldDrawGizmos(this)) { return; } OnValidate(); int layer = 0; Material material = m_DebugMaterial; if (!material) { return; } material.enableInstancing = true; Mesh mesh = m_DebugMesh; if (!mesh) { return; } int submeshIndex = 0; MaterialPropertyBlock properties = null; ShadowCastingMode castShadows = ShadowCastingMode.Off; bool receiveShadows = false; Camera emptyCamera = null; LightProbeUsage lightProbeUsage = LightProbeUsage.Off; LightProbeProxyVolume lightProbeProxyVolume = null; foreach (Matrix4x4[] matrices in m_DebugProbeMatricesList) { Graphics.DrawMeshInstanced(mesh, submeshIndex, material, matrices, matrices.Length, properties, castShadows, receiveShadows, layer, emptyCamera, lightProbeUsage, lightProbeProxyVolume); } }
private void OnEnable() { if (skeletonRenderer == null) { return; } if (copiedBlock == null) { copiedBlock = new MaterialPropertyBlock(); } mainMeshRenderer = skeletonRenderer.GetComponent <MeshRenderer>(); skeletonRenderer.GenerateMeshOverride -= HandleRender; skeletonRenderer.GenerateMeshOverride += HandleRender; if (!copyMeshRendererFlags) { return; } LightProbeUsage lightProbeUsage = mainMeshRenderer.lightProbeUsage; bool receiveShadows = mainMeshRenderer.receiveShadows; ReflectionProbeUsage reflectionProbeUsage = mainMeshRenderer.reflectionProbeUsage; ShadowCastingMode shadowCastingMode = mainMeshRenderer.shadowCastingMode; MotionVectorGenerationMode motionVectorGenerationMode = mainMeshRenderer.motionVectorGenerationMode; Transform probeAnchor = mainMeshRenderer.probeAnchor; for (int i = 0; i < partsRenderers.Count; i++) { SkeletonPartsRenderer skeletonPartsRenderer = partsRenderers[i]; if (!(skeletonPartsRenderer == null)) { MeshRenderer meshRenderer = skeletonPartsRenderer.MeshRenderer; meshRenderer.lightProbeUsage = lightProbeUsage; meshRenderer.receiveShadows = receiveShadows; meshRenderer.reflectionProbeUsage = reflectionProbeUsage; meshRenderer.shadowCastingMode = shadowCastingMode; meshRenderer.motionVectorGenerationMode = motionVectorGenerationMode; meshRenderer.probeAnchor = probeAnchor; } } }
public void ReadFromGameObject(int rootInstanceId, CombineConditionSettings combineConditions, bool copyBakedLighting, GameObject go, Transform t, MeshRenderer mr, Material mat) { matInstanceId = (combineConditions.sameMaterial ? mat.GetInstanceID() : combineConditions.combineCondition.matInstanceId); lightmapIndex = (copyBakedLighting ? mr.lightmapIndex : lightmapIndex = -1); shadowCastingMode = (combineConditions.sameShadowCastingMode ? mr.shadowCastingMode : combineConditions.combineCondition.shadowCastingMode); receiveShadows = (combineConditions.sameReceiveShadows ? mr.receiveShadows : combineConditions.combineCondition.receiveShadows); lightmapScale = (combineConditions.sameLightmapScale ? GetLightmapScale(mr) : combineConditions.combineCondition.lightmapScale); lightProbeUsage = (combineConditions.sameLightProbeUsage ? mr.lightProbeUsage : combineConditions.combineCondition.lightProbeUsage); reflectionProbeUsage = (combineConditions.sameReflectionProbeUsage ? mr.reflectionProbeUsage : combineConditions.combineCondition.reflectionProbeUsage); probeAnchor = (combineConditions.sameProbeAnchor ? mr.probeAnchor : combineConditions.combineCondition.probeAnchor); motionVectorGenerationMode = (combineConditions.sameMotionVectorGenerationMode ? mr.motionVectorGenerationMode : combineConditions.combineCondition.motionVectorGenerationMode); layer = (combineConditions.sameLayer ? go.layer : combineConditions.combineCondition.layer); #if UNITY_EDITOR #if !UNITY_2017 && !UNITY_2018 && !UNITY_2019_1 receiveGI = (combineConditions.sameReceiveGI ? mr.receiveGI : combineConditions.combineCondition.receiveGI); #endif staticEditorFlags = (combineConditions.sameStaticEditorFlags ? UnityEditor.GameObjectUtility.GetStaticEditorFlags(go) : combineConditions.combineCondition.staticEditorFlags); #endif this.rootInstanceId = rootInstanceId; // Debug.Log(go.name + " " + shadowCastingMode); }
private void OnEnable() { if (this.skeletonRenderer != null) { if (this.copiedBlock == null) { this.copiedBlock = new MaterialPropertyBlock(); } this.mainMeshRenderer = this.skeletonRenderer.GetComponent <MeshRenderer>(); this.skeletonRenderer.GenerateMeshOverride -= new Spine.Unity.SkeletonRenderer.InstructionDelegate(this.HandleRender); this.skeletonRenderer.GenerateMeshOverride += new Spine.Unity.SkeletonRenderer.InstructionDelegate(this.HandleRender); if (this.copyMeshRendererFlags) { LightProbeUsage lightProbeUsage = this.mainMeshRenderer.lightProbeUsage; bool receiveShadows = this.mainMeshRenderer.receiveShadows; ReflectionProbeUsage reflectionProbeUsage = this.mainMeshRenderer.reflectionProbeUsage; ShadowCastingMode shadowCastingMode = this.mainMeshRenderer.shadowCastingMode; MotionVectorGenerationMode motionVectorGenerationMode = this.mainMeshRenderer.motionVectorGenerationMode; Transform probeAnchor = this.mainMeshRenderer.probeAnchor; for (int i = 0; i < this.partsRenderers.Count; i++) { SkeletonPartsRenderer renderer = this.partsRenderers[i]; if (renderer != null) { MeshRenderer meshRenderer = renderer.MeshRenderer; meshRenderer.lightProbeUsage = lightProbeUsage; meshRenderer.receiveShadows = receiveShadows; meshRenderer.reflectionProbeUsage = reflectionProbeUsage; meshRenderer.shadowCastingMode = shadowCastingMode; meshRenderer.motionVectorGenerationMode = motionVectorGenerationMode; meshRenderer.probeAnchor = probeAnchor; } } } } }
protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); Renderer uo = (Renderer)obj; enabled = uo.enabled; shadowCastingMode = uo.shadowCastingMode; receiveShadows = uo.receiveShadows; motionVectorGenerationMode = uo.motionVectorGenerationMode; lightProbeUsage = uo.lightProbeUsage; reflectionProbeUsage = uo.reflectionProbeUsage; renderingLayerMask = uo.renderingLayerMask; sortingLayerName = uo.sortingLayerName; sortingLayerID = uo.sortingLayerID; sortingOrder = uo.sortingOrder; allowOcclusionWhenDynamic = uo.allowOcclusionWhenDynamic; lightProbeProxyVolumeOverride = ToID(uo.lightProbeProxyVolumeOverride); probeAnchor = ToID(uo.probeAnchor); lightmapIndex = uo.lightmapIndex; realtimeLightmapIndex = uo.realtimeLightmapIndex; lightmapScaleOffset = uo.lightmapScaleOffset; realtimeLightmapScaleOffset = uo.realtimeLightmapScaleOffset; sharedMaterials = ToID(uo.sharedMaterials); }
} // 0x000000018096BCD0-0x000000018096BDF0 public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, Transform probeAnchor, LightProbeUsage lightProbeUsage, [DefaultValue] /* 0x00000001800F6CB0-0x00000001800F6CE0 */ LightProbeProxyVolume lightProbeProxyVolume) { } // 0x000000018096C380-0x000000018096C570
extern private static void Internal_DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, Matrix4x4[] matrices, int count, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, int layer, Camera camera, LightProbeUsage lightProbeUsage, LightProbeProxyVolume lightProbeProxyVolume);
extern private static void Internal_DrawMeshInstancedIndirect(Mesh mesh, int submeshIndex, Material material, Bounds bounds, ComputeBuffer bufferWithArgs, int argsOffset, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, int layer, Camera camera, LightProbeUsage lightProbeUsage, LightProbeProxyVolume lightProbeProxyVolume);
public static void DrawMeshInstancedIndirect(Mesh mesh, int submeshIndex, Material material, Bounds bounds, ComputeBuffer bufferWithArgs, [uei.DefaultValue("0")] int argsOffset, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume) { if (!SystemInfo.supportsInstancing) { throw new InvalidOperationException("Instancing is not supported."); } else if (mesh == null) { throw new ArgumentNullException("mesh"); } else if (submeshIndex < 0 || submeshIndex >= mesh.subMeshCount) { throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range."); } else if (material == null) { throw new ArgumentNullException("material"); } else if (bufferWithArgs == null) { throw new ArgumentNullException("bufferWithArgs"); } if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null) { throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume"); } Internal_DrawMeshInstancedIndirect(mesh, submeshIndex, material, bounds, bufferWithArgs, argsOffset, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume); }
extern private static void Internal_DrawMesh(Mesh mesh, int submeshIndex, Matrix4x4 matrix, Material material, int layer, Camera camera, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, Transform probeAnchor, LightProbeUsage lightProbeUsage, LightProbeProxyVolume lightProbeProxyVolume);
public static void DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, List <Matrix4x4> matrices, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume) { if (matrices == null) { throw new ArgumentNullException("matrices"); } DrawMeshInstanced(mesh, submeshIndex, material, NoAllocHelpers.ExtractArrayFromListT(matrices), matrices.Count, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume); }
public static void DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, Matrix4x4[] matrices, [uei.DefaultValue("matrices.Length")] int count, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume) { if (!SystemInfo.supportsInstancing) { throw new InvalidOperationException("Instancing is not supported."); } else if (mesh == null) { throw new ArgumentNullException("mesh"); } else if (submeshIndex < 0 || submeshIndex >= mesh.subMeshCount) { throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range."); } else if (material == null) { throw new ArgumentNullException("material"); } else if (!material.enableInstancing) { throw new InvalidOperationException("Material needs to enable instancing for use with DrawMeshInstanced."); } else if (matrices == null) { throw new ArgumentNullException("matrices"); } else if (count < 0 || count > Mathf.Min(kMaxDrawMeshInstanceCount, matrices.Length)) { throw new ArgumentOutOfRangeException("count", String.Format("Count must be in the range of 0 to {0}.", Mathf.Min(kMaxDrawMeshInstanceCount, matrices.Length))); } else if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null) { throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume"); } if (count > 0) { Internal_DrawMeshInstanced(mesh, submeshIndex, material, matrices, count, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume); } }
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, Transform probeAnchor, LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume) { if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null) { throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume"); } Internal_DrawMesh(mesh, submeshIndex, matrix, material, layer, camera, properties, castShadows, receiveShadows, probeAnchor, lightProbeUsage, lightProbeProxyVolume); }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("批处理Root下的MeshRenderer组件", MessageType.Info); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Root:", GUILayout.Width(120)); _root = EditorGUILayout.ObjectField(_root, typeof(GameObject), true) as GameObject; EditorGUILayout.EndHorizontal(); GUI.enabled = _root; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Replace Material:", GUILayout.Width(120)); _mat = EditorGUILayout.ObjectField(_mat, typeof(Material), true) as Material; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Light Probes:", GUILayout.Width(120)); _lightProbe = (LightProbeUsage)EditorGUILayout.EnumPopup(_lightProbe); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Reflection Probes:", GUILayout.Width(120)); _reflectionProbe = (ReflectionProbeUsage)EditorGUILayout.EnumPopup(_reflectionProbe); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Cast Shadows:", GUILayout.Width(120)); _castShadows = (ShadowCastingMode)EditorGUILayout.EnumPopup(_castShadows); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Receive Shadows:", GUILayout.Width(120)); _receiveShadows = EditorGUILayout.Toggle(_receiveShadows); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set")) { MeshRenderer[] renderers = _root.GetComponentsInChildren <MeshRenderer>(true); for (int i = 0; i < renderers.Length; i++) { if (_mat) { Material[] materials = new Material[renderers[i].sharedMaterials.Length]; for (int j = 0; j < materials.Length; j++) { materials[j] = _mat; } renderers[i].sharedMaterials = materials; } renderers[i].lightProbeUsage = _lightProbe; renderers[i].reflectionProbeUsage = _reflectionProbe; renderers[i].shadowCastingMode = _castShadows; renderers[i].receiveShadows = _receiveShadows; } GlobalTools.LogInfo("[" + _root.name + "] 设置完成!共设置了 " + renderers.Length + " 处!"); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; }
public static void DrawMeshInstancedProcedural(Mesh mesh, int submeshIndex, Material material, Bounds bounds, int count, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0, Camera camera = null, LightProbeUsage lightProbeUsage = LightProbeUsage.BlendProbes, LightProbeProxyVolume lightProbeProxyVolume = null) { if (!SystemInfo.supportsInstancing) { throw new InvalidOperationException("Instancing is not supported."); } else if (mesh == null) { throw new ArgumentNullException("mesh"); } else if (submeshIndex < 0 || submeshIndex >= mesh.subMeshCount) { throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range."); } else if (material == null) { throw new ArgumentNullException("material"); } else if (count <= 0) { throw new ArgumentOutOfRangeException("count"); } else if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null) { throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume"); } if (count > 0) { Internal_DrawMeshInstancedProcedural(mesh, submeshIndex, material, bounds, count, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume); } }