コード例 #1
0
        public static void BakeTexture(List <ViewPart> parts, Rect[] atlasUVOffsets, BodyColorMaterialProperties bodyColor, RenderTexture atlasRenderTexture)
        {
            BakeMaterialProperties bakeMaterialProperties = new BakeMaterialProperties(null);
            RenderTexture          active = RenderTexture.active;

            RenderTexture.active = atlasRenderTexture;
            GL.Clear(true, true, new Color32(0, 0, 0, 0));
            for (int i = 0; i < parts.Count; i++)
            {
                ViewPart viewPart    = parts[i];
                Material material    = new Material(viewPart.HasMaterialProperties(typeof(EquipmentMaterialProperties)) ? AvatarService.EquipmentBakeShader : AvatarService.BodyBakeShader);
                Texture  maskTexture = viewPart.GetMaskTexture();
                viewPart.ApplyMaterialProperties(material);
                bodyColor.Apply(material);
                Rect rect = atlasUVOffsets[i];
                bakeMaterialProperties.AtlasOffsetU      = rect.x;
                bakeMaterialProperties.AtlasOffsetV      = rect.y;
                bakeMaterialProperties.AtlasOffsetScaleU = rect.width;
                bakeMaterialProperties.AtlasOffsetScaleV = rect.height;
                bakeMaterialProperties.Apply(material);
                atlasRenderTexture.DiscardContents();
                Graphics.Blit(maskTexture, atlasRenderTexture, material);
                Object.Destroy(material);
            }
            RenderTexture.active = active;
        }
コード例 #2
0
        public void SetupRenderer(GameObject gameObject, AvatarModel model, ref Renderer rend)
        {
            if (rend == null)
            {
                rend = this.MeshDef.CreateRenderer(gameObject);
                model.Definition.RenderProperties.Apply(rend);
            }
            Material material = this.GetMaterial(false);
            BodyColorMaterialProperties bodyColorMaterialProperties = new BodyColorMaterialProperties(model.BeakColor, model.BellyColor, model.BodyColor);

            bodyColorMaterialProperties.Apply(material);
            this.ApplyMaterialProperties(material);
            ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
            rend.sharedMaterial = material;
            this.MeshDef.ApplyMesh(gameObject, null);
        }
コード例 #3
0
 public void Update()
 {
     if (base.IsBusy && loadingEquipmentRequest.Finished && loadingDecalRequest.Finished)
     {
         cleanupCurrent();
         switchLoadingRequestsToCurrent();
         setupRenderer();
         stopWork();
     }
     if (bodyMatProps != null && rend != null)
     {
         Material sharedMaterial = rend.sharedMaterial;
         if (sharedMaterial != null)
         {
             bodyMatProps.Apply(sharedMaterial);
             bodyMatProps = null;
         }
     }
 }