Exemplo n.º 1
0
        private void modifyMaterials(Color bodyColor)
        {
            Shader   shader   = Shader.Find("CpRemix/Particles/Unlit Color");
            Material material = new Material(shader);

            material.color = bodyColor;
            SkinnedMeshRenderer[] componentsInChildren = penguin.GetComponentsInChildren <SkinnedMeshRenderer>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                Material sharedMaterial = componentsInChildren[i].sharedMaterial;
                if (sharedMaterial != null)
                {
                    if (sharedMaterial.shader.name == AvatarService.EquipmentPreviewShader.name)
                    {
                        sharedMaterial.shader = AvatarService.EquipmentScreenshotShader;
                    }
                    else
                    {
                        ComponentExtensions.DestroyIfInstance(componentsInChildren[i].sharedMaterial);
                        componentsInChildren[i].sharedMaterial = material;
                    }
                }
                else
                {
                    Log.LogErrorFormatted(this, "Null material in {0}", componentsInChildren[i].name);
                }
                componentsInChildren[i].updateWhenOffscreen = true;
            }
        }
Exemplo n.º 2
0
 private void setupRenderer()
 {
     ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
     rend.sharedMaterial = meshDef.CreateCombinedMaterial(combineRequest.Atlas);
     meshDef.ApplyMesh(base.gameObject, combineRequest.Mesh);
     rend.enabled = true;
 }
            bool IEnumerator.MoveNext()
            {
                switch (this.__1__state)
                {
                case 0:
                    this.__1__state = -1;
                    goto IL_17A;

                case 2:
                    this.__1__state = -1;
                    if (!this._busy_5__a)
                    {
                        goto IL_149;
                    }
                    goto IL_79;

                case 3:
                    this.__1__state = -1;
                    goto IL_179;
                }
                bool result = false;

                return(result);

IL_79:
                try
                {
                    Profiler.BeginSample("ApplyCombinedMesh_" + this._step_5__b++);
                    this._busy_5__a = this._current_5__9.Value.MoveNext();
                    Profiler.EndSample();
                }
                catch (Exception ex)
                {
                    Log.LogException(this.__4__this, ex);
                    ComponentExtensions.DestroyIfInstance(this._current_5__9.Key.Mesh);
                    ComponentExtensions.DestroyIfInstance(this._current_5__9.Key.Atlas);
                    this._current_5__9.Key.Mesh  = null;
                    this._current_5__9.Key.Atlas = null;
                    goto IL_149;
                }
                this.__2__current = true;
                this.__1__state   = 2;
                result            = true;
                return(result);

IL_149:
                this._current_5__9.Key.Finished = true;
IL_179:
IL_17A:
                if (this.__4__this.queue.Count > 0)
                {
                    this._current_5__9 = this.__4__this.queue.Dequeue();
                    this._step_5__b    = 0;
                    goto IL_79;
                }
                this.__2__current = false;
                this.__1__state   = 3;
                result            = true;
                return(result);
            }
Exemplo n.º 4
0
 public void OnDestroy()
 {
     if (m_Material != null)
     {
         ComponentExtensions.DestroyIfInstance(m_Material);
         m_Material = null;
     }
 }
Exemplo n.º 5
0
        public void CleanUp(GameObject go)
        {
            Renderer component = go.GetComponent <Renderer>();

            if (component != null)
            {
                ComponentExtensions.DestroyIfInstance(component.sharedMaterial);
                if (this.MeshDef != null)
                {
                    this.MeshDef.CleanUp(go);
                }
            }
        }
Exemplo n.º 6
0
        public void SetupRenderer(GameObject gameObject, DceModel model, ref Renderer rend)
        {
            if (rend == null)
            {
                rend = MeshDef.CreateRenderer(gameObject);
            }
            Material material = GetMaterial();

            ApplyMaterialProperties(material);
            ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
            rend.sharedMaterial = material;
            MeshDef.ApplyMesh(gameObject);
        }
        public override void CleanUp(GameObject go)
        {
            ComponentExtensions.DestroyIfInstance(getSharedMesh(go));
            setSharedMesh(go, null);
            Material sharedMaterial = getSharedMaterial(go);

            if ((bool)sharedMaterial)
            {
                if (sharedMaterial.HasProperty("_MainTex"))
                {
                    ComponentExtensions.DestroyIfInstance(sharedMaterial.mainTexture);
                }
                ComponentExtensions.DestroyIfInstance(sharedMaterial);
                setSharedMaterial(go, null);
            }
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
 protected override void cleanup()
 {
     meshDef.CleanUp(base.gameObject);
     ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
     rend.enabled = false;
     if (partsRequest != null)
     {
         outfitService.Unload(partsRequest);
         partsRequest = null;
     }
     if (decalsRequest != null)
     {
         outfitService.Unload(decalsRequest);
         decalsRequest = null;
     }
     combineRequest = null;
 }
Exemplo n.º 10
0
 protected override void cleanup()
 {
     this.meshDef.CleanUp(base.gameObject);
     ComponentExtensions.DestroyIfInstance(this.rend.sharedMaterial);
     this.rend.enabled = false;
     if (this.partsRequest != null)
     {
         this.outfitService.Unload <EquipmentViewDefinition>(this.partsRequest);
         this.partsRequest = null;
     }
     if (this.decalsRequest != null)
     {
         this.outfitService.Unload <Texture2D>(this.decalsRequest);
         this.decalsRequest = null;
     }
     this.combineRequest = null;
 }
Exemplo n.º 11
0
 private IEnumerator <bool> fibre()
 {
     while (true)
     {
         if (queue.Count > 0)
         {
             KeyValuePair <Request, IEnumerator> current = queue.Dequeue();
             int  step = 0;
             bool busy;
             do
             {
                 try
                 {
                     int num;
                     step = (num = step) + 1;
                     Profiler.BeginSample("ApplyCombinedMesh_" + num);
                     busy = current.Value.MoveNext();
                     Profiler.EndSample();
                 }
                 catch (Exception ex)
                 {
                     Log.LogException(this, ex);
                     ComponentExtensions.DestroyIfInstance(current.Key.Mesh);
                     ComponentExtensions.DestroyIfInstance(current.Key.Atlas);
                     current.Key.Mesh  = null;
                     current.Key.Atlas = null;
                     break;
                 }
                 yield return(true);
             }while (busy);
             current.Key.Finished = true;
         }
         else
         {
             yield return(false);
         }
     }
 }
Exemplo n.º 12
0
 protected override void cleanup()
 {
     meshDef.CleanUp(base.gameObject);
     ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
     rend.enabled = false;
 }