private void RenderTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e) { var template = RenderTemplates.SelectedValue as string; Renderers.Clear(); Renderers.AddRange(TemplateHelper.GetRenderers(template)); SelectedRenderer = GetSelectedRenderer(template); }
public void AddRenderingSteps(Renderer[] renderers, Color outlineColor, int thickness, Shader drawSilhouettesShader) { if ((renderers == null) || (renderers.Length == 0)) { Debug.LogError("target to be rendered not set"); return; } Material currentMat = null; if (materialCounter >= Materials.Count) { currentMat = new Material(drawSilhouettesShader); Materials.Add(currentMat); } else { currentMat = Materials[materialCounter]; } materialCounter++; currentMat.SetColor(silhouetteColorID, OutlineInfo.Encode(outlineColor, thickness)); int renderersStart = Renderers.Count; Renderers.AddRange(renderers); Renderer r = null; for (int i = renderersStart; i < Renderers.Count; i++) { r = Renderers[i]; if (r.isVisible) { if (r is SkinnedMeshRenderer) { SkinnedMeshRenderer skinned = (SkinnedMeshRenderer)r; if (skinned.sharedMesh) { for (int c = 0; c < skinned.sharedMesh.subMeshCount; c++) { CommandBuffer.DrawRenderer(r, currentMat, c, 0); } } } else { CommandBuffer.DrawRenderer(r, currentMat, 0, 0); } } } //TODO: probabilmente Renderers può essere eliminato e può essere usato solo l'array argomento del metodo renderers }
public override void Initialize(IItemOfInterest worlditem) { base.Initialize(worlditem); NObject = gameObject.GetComponent <TNObject> (); Renderers.Clear(); Renderers.AddRange(gameObject.GetComponentsInChildren <Renderer> (true)); for (int i = 0; i < Renderers.Count; i++) { Renderers [i].gameObject.layer = Globals.LayerNumWorldItemActive; } SetHairLength(HairLength); /*if (HairLength == CharacterHairLength.Long) { * if (ShortHairRenderer != null) { * ShortHairRenderer.enabled = false; * } * if (LongHairRenderer != null) { * LongHairRenderer.enabled = true; * } * * } else if (HairLength == CharacterHairLength.Short) { * if (ShortHairRenderer != null) { * ShortHairRenderer.enabled = true; * } * if (LongHairRenderer != null) { * LongHairRenderer.enabled = false; * } * * } else { * if (ShortHairRenderer != null) { * ShortHairRenderer.enabled = false; * } * if (LongHairRenderer != null) { * LongHairRenderer.enabled = false; * } * }*/ }
protected virtual void OnLoadObjectRenderers() { Renderers.AddRange(GetComponentsInChildren <Renderer>()); }
private void Awake() { Renderers.AddRange(GetComponentsInChildren <MeshRenderer>()); Renderers.AddRange(GetComponentsInChildren <SkinnedMeshRenderer>()); }
public void Start() { if (CharacterName == "[Player]") { if (Flags.Gender != (int)Profile.Get.CurrentGame.Character.Gender) { gameObject.SetActive(false); return; } else { FaceTextureName = Profile.Get.CurrentGame.Character.FaceTextureName; BodyTextureName = Profile.Get.CurrentGame.Character.BodyTextureName; HairTextureName = Profile.Get.CurrentGame.Character.HairTextureName; HairLength = Profile.Get.CurrentGame.Character.HairLength; HairColor = Profile.Get.CurrentGame.Character.HairColor; } } else { CharacterTemplate template = null; if (Characters.GetTemplate(false, CharacterName, out template)) { if (string.IsNullOrEmpty(FaceTextureName)) { FaceTextureName = template.StateTemplate.FaceTextureName; } if (string.IsNullOrEmpty(BodyTextureName)) { BodyTextureName = template.StateTemplate.BodyTextureName; } if (template.StateTemplate.RelatedToPlayer) { FaceTextureName = Characters.MatchFaceTextureEthnicity(FaceTextureName, Profile.Get.CurrentGame.Character.Ethnicity); } HairTextureName = BodyTextureName; HairLength = template.StateTemplate.HairLength; HairColor = template.StateTemplate.HairColor; Debug.Log("Template: " + CharacterName + ", Face name: " + FaceTextureName + ", Body Name: " + BodyTextureName); } else { Debug.Log("COULDN'T GET TEMPLATE IN CUTSCENE BODY"); } } Renderers.Clear(); Renderers.AddRange(transform.GetComponentsInChildren <Renderer> ()); gameObject.SetLayerRecursively(Globals.LayerNumScenery); Texture2D bodyTexture = null; Texture2D faceTexture = null; Texture2D hairTexture = null; Material bodyMaterial = null; Material faceMaterial = null; Material hairMaterial = null; CharacterBody body = this; //update textures bodyMaterial = body.MainMaterial; if (bodyMaterial == null) { bodyMaterial = new Material(Characters.Get.CharacterBodyMaterial); bodyMaterial.name = "NewBodyMaterial"; body.MainMaterial = bodyMaterial; } faceMaterial = body.FaceMaterial; if (faceMaterial == null) { faceMaterial = new Material(Characters.Get.CharacterFaceMaterial); faceMaterial.name = "NewFaceMaterial"; body.FaceMaterial = faceMaterial; } hairMaterial = body.HairMaterial; if (hairMaterial == null) { hairMaterial = new Material(Characters.Get.CharacterHairMaterial); hairMaterial.name = "NewHairMaterial"; body.HairMaterial = hairMaterial; } if (Mods.Get.Runtime.BodyTexture(ref bodyTexture, BodyTextureName)) { bodyMaterial.SetTexture("_MainTex", bodyTexture); } else { Debug.Log("Couldn't get body texture " + BodyTextureName); } if (Mods.Get.Runtime.FaceTexture(ref faceTexture, FaceTextureName)) { faceMaterial.SetTexture("_MainTex", faceTexture); } else { Debug.Log("Couldn't get body texture " + FaceTextureName); } if (Mods.Get.Runtime.BodyTexture(ref hairTexture, HairTextureName)) { hairMaterial.SetTexture("_MainTex", hairTexture); //now apply the hair color - we use a full red texture to color the whole texture hairMaterial.SetColor("_EyeColor", Colors.Get.HairColor(HairColor)); } body.SetHairLength(HairLength); }