public RendererProperties(Renderer renderer) { this.ReceiveShadows = renderer.receiveShadows; this.ReflectionProbeUsage = renderer.reflectionProbeUsage; this.ShadowCastingMode = renderer.shadowCastingMode; this.UseLightProbes = (renderer.lightProbeUsage == LightProbeUsage.BlendProbes); }
public RendererProperties(Renderer renderer) { ReceiveShadows = renderer.receiveShadows; ReflectionProbeUsage = renderer.reflectionProbeUsage; ShadowCastingMode = renderer.shadowCastingMode; UseLightProbes = renderer.lightProbeUsage == LightProbeUsage.BlendProbes; }
protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); Terrain uo = (Terrain)obj; terrainData = ToID(uo.terrainData); treeDistance = uo.treeDistance; treeBillboardDistance = uo.treeBillboardDistance; treeCrossFadeLength = uo.treeCrossFadeLength; treeMaximumFullLODCount = uo.treeMaximumFullLODCount; detailObjectDistance = uo.detailObjectDistance; detailObjectDensity = uo.detailObjectDensity; heightmapPixelError = uo.heightmapPixelError; heightmapMaximumLOD = uo.heightmapMaximumLOD; basemapDistance = uo.basemapDistance; lightmapIndex = uo.lightmapIndex; realtimeLightmapIndex = uo.realtimeLightmapIndex; lightmapScaleOffset = uo.lightmapScaleOffset; realtimeLightmapScaleOffset = uo.realtimeLightmapScaleOffset; freeUnusedRenderingResources = uo.freeUnusedRenderingResources; reflectionProbeUsage = uo.reflectionProbeUsage; materialTemplate = ToID(uo.materialTemplate); drawHeightmap = uo.drawHeightmap; drawTreesAndFoliage = uo.drawTreesAndFoliage; patchBoundsMultiplier = uo.patchBoundsMultiplier; treeLODBiasMultiplier = uo.treeLODBiasMultiplier; collectDetailPatches = uo.collectDetailPatches; editorRenderFlags = uo.editorRenderFlags; preserveTreePrototypeLayers = uo.preserveTreePrototypeLayers; allowAutoConnect = uo.allowAutoConnect; groupingID = uo.groupingID; drawInstanced = uo.drawInstanced; shadowCastingMode = uo.shadowCastingMode; }
public void CopySettingsFrom(Terrain terrain) { if (terrain == null) { return; } // base settings GroupingID = terrain.groupingID; AutoConnect = terrain.allowAutoConnect; DrawHeightmap = terrain.drawHeightmap; DrawInstanced = terrain.drawInstanced; PixelError = terrain.heightmapPixelError; BaseMapDistance = terrain.basemapDistance; ShadowCastingMode = terrain.shadowCastingMode; MaterialTemplate = terrain.materialTemplate; ReflectionProbeUsage = terrain.reflectionProbeUsage; #if UNITY_2019_2_OR_NEWER #else MaterialType = terrain.materialType; LegacySpecular = terrain.legacySpecular; LegacyShininess = terrain.legacyShininess; #endif // mesh resolution TerrainWidth = terrain.terrainData.size.x; TerrainHeight = terrain.terrainData.size.y; TerrainLength = terrain.terrainData.size.z; DetailResolutaion = terrain.terrainData.detailResolution; DetailResolutionPerPatch = terrain.terrainData.detailResolutionPerPatch; // texture resolution BaseTextureResolution = terrain.terrainData.baseMapResolution; AlphaMapResolution = terrain.terrainData.alphamapResolution; HeightMapResolution = terrain.terrainData.heightmapResolution; // tree and details DrawTreesAndFoliage = terrain.drawTreesAndFoliage; BakeLightProbesForTrees = terrain.bakeLightProbesForTrees; DeringLightProbesForTrees = terrain.deringLightProbesForTrees; PreserveTreePrototypeLayers = terrain.preserveTreePrototypeLayers; DetailObjectDistance = terrain.detailObjectDistance; CollectDetailPatches = terrain.collectDetailPatches; DetailObjectDensity = terrain.detailObjectDensity; TreeDistance = terrain.treeDistance; TreeBillboardDistance = terrain.treeBillboardDistance; TreeCrossFadeLength = terrain.treeCrossFadeLength; TreeMaximumFullLODCount = terrain.treeMaximumFullLODCount; // grass wind WavingGrassStrength = terrain.terrainData.wavingGrassStrength; WavingGrassSpeed = terrain.terrainData.wavingGrassSpeed; WavingGrassAmount = terrain.terrainData.wavingGrassAmount; WavingGrassTint = terrain.terrainData.wavingGrassTint; }
public void CopySettingsFrom(TerrainSettings other) { if (other == null) { return; } GroupingID = other.GroupingID; AutoConnect = other.AutoConnect; DrawHeightmap = other.DrawHeightmap; DrawInstanced = other.DrawInstanced; PixelError = other.PixelError; BaseMapDistance = other.BaseMapDistance; ShadowCastingMode = other.ShadowCastingMode; MaterialTemplate = other.MaterialTemplate; ReflectionProbeUsage = other.ReflectionProbeUsage; #if UNITY_2019_2_OR_NEWER #else MaterialType = other.MaterialType; LegacySpecular = other.LegacySpecular; LegacyShininess = other.LegacyShininess; #endif // mesh resolution TerrainWidth = other.TerrainWidth; TerrainHeight = other.TerrainHeight; TerrainLength = other.TerrainLength; DetailResolutaion = other.DetailResolutaion; DetailResolutionPerPatch = other.DetailResolutionPerPatch; // texture resolution BaseTextureResolution = other.BaseTextureResolution; AlphaMapResolution = other.AlphaMapResolution; HeightMapResolution = other.HeightMapResolution; // tree and details DrawTreesAndFoliage = other.DrawTreesAndFoliage; BakeLightProbesForTrees = other.BakeLightProbesForTrees; DeringLightProbesForTrees = other.DeringLightProbesForTrees; PreserveTreePrototypeLayers = other.PreserveTreePrototypeLayers; DetailObjectDistance = other.DetailObjectDistance; CollectDetailPatches = other.CollectDetailPatches; DetailObjectDensity = other.DetailObjectDensity; TreeDistance = other.TreeDistance; TreeBillboardDistance = other.TreeBillboardDistance; TreeCrossFadeLength = other.TreeCrossFadeLength; TreeMaximumFullLODCount = other.TreeMaximumFullLODCount; // grass wind WavingGrassStrength = other.WavingGrassStrength; WavingGrassSpeed = other.WavingGrassSpeed; WavingGrassAmount = other.WavingGrassAmount; WavingGrassTint = other.WavingGrassTint; }
/// <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; }
private void DrawReflectionProbeModeGUI() { GUI.enabled = PropertyField("useCubemapReflections").boolValue; var prop = serializedObject.FindProperty("reflectionProbeUsage"); ReflectionProbeUsage val = (ReflectionProbeUsage)prop.intValue; val = (ReflectionProbeUsage)EditorGUILayout.EnumPopup("Reflection Probe Usage", val); prop.intValue = (int)val; GUI.enabled = true; }
/// <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> 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> /// 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; }
private static int set_reflectionProbeUsage(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); Renderer renderer = (Renderer)obj; ReflectionProbeUsage reflectionProbeUsage = (ReflectionProbeUsage)((int)ToLua.CheckObject(L, 2, typeof(ReflectionProbeUsage))); renderer.reflectionProbeUsage = reflectionProbeUsage; result = 0; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index reflectionProbeUsage on a nil value"); } return(result); }
private static int get_reflectionProbeUsage(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); Renderer renderer = (Renderer)obj; ReflectionProbeUsage reflectionProbeUsage = renderer.get_reflectionProbeUsage(); ToLua.Push(L, reflectionProbeUsage); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index reflectionProbeUsage on a nil value"); } return(result); }
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; } } }
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); }
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; } } } } }
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 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; }