//do I need to make a new block every time?
    void SetPropertyBlocks()
    {
        if (extraColors.Length > 0)
        {
            mpb = new MaterialPropertyBlock();
            mpb.SetColor("_Color", GetRandomColor());
            if (texture != null)
            {
                mpb.SetTexture("_MainTex", texture);
            }
            mr.SetPropertyBlock(mpb, 0);

            for (int i = 0; i < extraColors.Length; i++)
            {
                mpb.SetColor("_Color", extraColors[i]);
                if (texture != null)
                {
                    mpb.SetTexture("_MainTex", texture);
                }
                mr.SetPropertyBlock(mpb, i + 1);
            }
        }
        else
        {
            mpb = new MaterialPropertyBlock();
            mpb.SetColor("_Color", GetRandomColor());
            if (texture != null)
            {
                mpb.SetTexture("_MainTex", texture);
            }
            mr.SetPropertyBlock(mpb);
        }
    }
Example #2
0
    private void PreviewTurret()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray.origin, ray.direction, out hit, 999, Mask))
        {
            if (hit.transform.gameObject.tag != "turret")
            {
                newTurretPreview.transform.position = hit.point + (hit.normal * -3.0f);
            }
        }
        else
        {
            newTurretPreview.transform.position = ray.origin * -3;
        }

        if (turretProperties.canBePlaced && turretProperties.isInTurretZone && spawnedTurrets.Count < GameManager.Get().maxTurrets)
        {
            material.SetColor("_BaseColor", Color.green);
            turretMaterial.SetPropertyBlock(material);
        }
        else
        {
            material.SetColor("_BaseColor", Color.red);
            turretMaterial.SetPropertyBlock(material);
        }
    }
Example #3
0
    private void OnDeath()
    {
        mr.material = DeathMaterial;
        enabled     = true;

        materialProperties.SetFloat("_Dissolve", -1);
        mr.SetPropertyBlock(materialProperties);
    }
Example #4
0
 public void SetPropertyColor(Color color)
 {
     _materialProperty = new MaterialPropertyBlock();
     _skinnedMeshRendererOne.SetPropertyBlock(_materialProperty, 0);
     _skinnedMeshRendererTwo.SetPropertyBlock(_materialProperty, 0);
     _materialProperty.SetColor("_Color", color);
     _skinnedMeshRendererOne.SetPropertyBlock(_materialProperty, 0);
     _skinnedMeshRendererTwo.SetPropertyBlock(_materialProperty, 0);
 }
Example #5
0
    private void UpdateOutline()
    {
        if (meshRenderer == null)
        {
            return;
        }

        if (mpb == null)
        {
            mpb = new MaterialPropertyBlock();
        }

        //머리 색상
        meshRenderer.GetPropertyBlock(mpb, 8);
        mpb.SetColor("_Color", hair_Color);
        mpb.SetColor("_ColorDim", hair_Color * 1.5f);
        mpb.SetColor("_ColorDimExtra", hair_Color);
        mpb.SetColor("_ColorDimExtra", hair_Color);
        meshRenderer.SetPropertyBlock(mpb, 8);

        //피부 색상
        meshRenderer.GetPropertyBlock(mpb, 0);
        mpb.SetColor("_Color", skin_Color);
        mpb.SetColor("_ColorDim", skin_Color * skin_Color);
        mpb.SetColor("_ColorDimExtra", skin_Color * skin_Color * skin_Color);
        meshRenderer.SetPropertyBlock(mpb, 0);
        meshRenderer.GetPropertyBlock(mpb, 1);
        mpb.SetColor("_Color", skin_Color * 1.3f);
        mpb.SetColor("_ColorDim", skin_Color * skin_Color * 1.3f);
        mpb.SetColor("_ColorDimExtra", skin_Color * skin_Color * skin_Color * 1.3f);
        meshRenderer.SetPropertyBlock(mpb, 1);
        meshRenderer.GetPropertyBlock(mpb, 2);
        mpb.SetColor("_Color", skin_Color * 1.3f);
        mpb.SetColor("_ColorDim", skin_Color * skin_Color * 1.3f);
        mpb.SetColor("_ColorDimExtra", skin_Color * skin_Color * skin_Color * 1.3f);
        meshRenderer.SetPropertyBlock(mpb, 2);

        //옷 색상
        meshRenderer.GetPropertyBlock(mpb, 3);
        mpb.SetColor("_Color", cloth_Color);
        mpb.SetColor("_ColorDim", cloth_Color * cloth_Color);
        mpb.SetColor("_ColorDimExtra", cloth_Color * cloth_Color * cloth_Color);
        meshRenderer.SetPropertyBlock(mpb, 3);
        meshRenderer.GetPropertyBlock(mpb, 6);
        mpb.SetColor("_Color", cloth_Color * 1.5f);
        mpb.SetColor("_ColorDim", cloth_Color * cloth_Color * 1.5f);
        mpb.SetColor("_ColorDimExtra", cloth_Color * cloth_Color * cloth_Color * 1.5f);
        meshRenderer.SetPropertyBlock(mpb, 6);

        //눈
        meshRenderer.GetPropertyBlock(mpb, 2);
        mpb.SetTexture("_MainTex", eye_Tex[eye_Num]);
        meshRenderer.SetPropertyBlock(mpb, 2);

        //입
        meshRenderer.GetPropertyBlock(mpb, 1);
        mpb.SetTexture("_MainTex", mouth_Tex[mouth_Num]);
        meshRenderer.SetPropertyBlock(mpb, 1);
    }
Example #6
0
 public void SetColor(Color color)
 {
     Debug.Log(color);
     block.SetColor("_Color", color);
     //block.SetTexture("_MainTex", texture);
     render.SetPropertyBlock(block);
 }
Example #7
0
 void ApplyPropertyBlocks()
 {
     for (int i = 0; i != materials.Length; i++)
     {
         smr.SetPropertyBlock(materials[i].materialProps, materials[i].materialIndex);
     }
 }
Example #8
0
    private void Awake()
    {
        mr = GetComponentInChildren <SkinnedMeshRenderer>();

        if (mr == null)
        {
            Debug.LogError("CharacterMaterialController: Awake: Could not find skinned mesh renderer");
            return;
        }

        materialProperties = new MaterialPropertyBlock();

        ThingController thingController = GetComponent <ThingController>();

        if (thingController != null)
        {
            thingController.OnMouseEnter.AddListener(() => { Highlight(true); });
            thingController.OnMouseLeave.AddListener(() => { Highlight(false); });
        }

        if (DeathMaterial != null)
        {
            MonsterCharacter character = GetComponent <MonsterCharacter>();
            if (character != null)
            {
                character.OnDeath.AddListener(OnDeath);
            }
        }

        materialProperties.SetColor("_OutlineColor", OutlineColor);
        materialProperties.SetFloat("_Outline", OutlineWidthDisabled);
        mr.SetPropertyBlock(materialProperties);

        enabled = false;
    }
Example #9
0
        void OnDisable()
        {
            if (smrProps == null)
            {
                smrProps = new MaterialPropertyBlock();
            }

            smr.GetPropertyBlock(smrProps);
            {
                if (headInstance.shaderParamFloats != null)                //TODO introduce IsCreated() or similar?
                {
                    SnappersHeadDefinition.ResetShaderParam(ref headInstance);
                    SnappersHeadDefinition.ApplyShaderParam(ref headInstance, smrProps);
                }
            }
            smr.SetPropertyBlock(smrProps);
        }
 void UpdateOutline(bool outline)
 {
     mpb = new MaterialPropertyBlock();
     spriteRenderer.GetPropertyBlock(mpb);
     mpb.SetFloat("_Outline", outline ? 1f : 0);
     mpb.SetColor("_OutlineColor", color);
     mpb.SetFloat("_OutlineSize", outlineSize);
     spriteRenderer.SetPropertyBlock(mpb);
 }
Example #11
0
    private void OnEnable()
    {
        this._photoBlock = new MaterialPropertyBlock();
        SkinnedMeshRenderer componentInChildren = this.burnTarget.GetComponentInChildren <SkinnedMeshRenderer>();

        componentInChildren.GetPropertyBlock(this._photoBlock);
        this._photoBlock.SetFloat("_BurnAmount", 0f);
        componentInChildren.SetPropertyBlock(this._photoBlock);
    }
Example #12
0
    private void ChangeTexture(int i)
    {
        // Get the property block.
        _renderer.GetPropertyBlock(_propBlock);

        // Assign our new values
        _propBlock.SetTexture("_Diffuse", butteryflySets[i].diffuse);
        _propBlock.SetTexture("_Normal", butteryflySets[i].normal);

        // Apply the edited values to the renderer.
        _renderer.SetPropertyBlock(_propBlock);
    }
Example #13
0
        //Vector4[] originalSensorsPos = new Vector4[VertExmotion.MAX_SENSOR];

        void LateUpdate()
        {
            if (m_reference == null)
            {
                return;
            }

            if (m_meshRenderer == null && m_skinMeshRenderer == null)
            {
                return;
            }

            //get shader properties from original
            m_matPropBlk = m_reference.m_matPropBlk;


            if (newSensorsPos.Length != m_reference.m_shaderSensorPos.Length)
            {
                newSensorsPos = new Vector4[m_reference.m_shaderSensorPos.Length];
            }

            for (int i = 0; i < m_reference.m_shaderSensorPos.Length; ++i)
            {
                newSensorsPos[i] = transform.TransformPoint(m_reference.transform.InverseTransformPoint(m_reference.m_shaderSensorPos[i]));
            }
            m_matPropBlk.SetVectorArray("KVM_SensorPosition", newSensorsPos);

            if (m_meshRenderer != null)
            {
                m_meshRenderer.SetPropertyBlock(m_reference.m_matPropBlk);
            }
            if (m_skinMeshRenderer != null)
            {
                m_skinMeshRenderer.SetPropertyBlock(m_reference.m_matPropBlk);
            }

            //restore values of the original
            m_matPropBlk.SetVectorArray("KVM_SensorPosition", m_reference.m_shaderSensorPos);

            if (m_copyDeltaPosition)
            {
                transform.position += m_reference.transform.position - m_referenceLastPosition;
            }

            if (m_copyRotation)
            {
                transform.rotation = m_reference.transform.rotation;
            }

            m_referenceLastPosition = m_reference.transform.position;
        }
Example #14
0
    public void Update()
    {
        AnimatedGO.GetPropertyBlock(materialPropertyBlock);
        materialPropertyBlock.SetFloat("_Visible", Visibility);
        AnimatedGO.SetPropertyBlock(materialPropertyBlock);

        if ((bluePlayer.transform.position - transform.position).sqrMagnitude < 2 && Visibility < 1)
        {
            FadeInMaterial();
        }
        else if ((bluePlayer.transform.position - transform.position).sqrMagnitude > 2 && Visibility > 0)
        {
            FadeOutMaterial();
        }
    }
Example #15
0
        private void Awake()
        {
            MaterialPropertyBlock materialBlock = new MaterialPropertyBlock();

            materialBlock.SetColor("_Color", Random.ColorHSV());
            SkinnedMeshRenderer renderer = GetComponentInChildren <SkinnedMeshRenderer>();

            renderer.SetPropertyBlock(materialBlock, 0);

            _startPos         = transform.position;
            _firstDestination = new Vector3(Random.Range(-12f, 12f), 0f, Random.Range(20f, 30f));
            _lastDestination  = new Vector3(0f, 0f, 220f);

            _agentAnimationController = new AgentAnimationController(this);
            _agentMover = new AgentMover(this);
            _agent      = GetComponent <NavMeshAgent>();

            //Zorluk Ayarları
            _agent.stoppingDistance = Random.Range(0f, 4f);
        }
        void OnWillRenderObject()
        {
            //If the merge method not is Only Anima2d Meshes, ignore this render
            if (mergeMethodUsed != MergeMethod.OnlyAnima2dMeshes)
            {
                return;
            }

            if (materialPropertyBlock != null)
            {
                if (atlasForRenderInChar != null)
                {
                    materialPropertyBlock.SetTexture("_MainTex", atlasForRenderInChar);
                }
                cachedSkinnedRenderer.SetPropertyBlock(materialPropertyBlock);
            }
            if (materialPropertyBlock == null)
            {
                materialPropertyBlock = new MaterialPropertyBlock();
            }
        }
Example #17
0
 private void UpdateShader(ShaderVariables variables)
 {
     if (emotiveRenderer != null)
     {
         emotiveRenderer.GetPropertyBlock(emotivePropertyBlock);
     }
     else if (emotiveRendererSkinned != null)
     {
         emotiveRendererSkinned.GetPropertyBlock(emotivePropertyBlock);
     }
     emotivePropertyBlock.SetFloat("_Smoothness", variables.smoothness);
     if (variables.emotionTexure != null)
     {
         emotivePropertyBlock.SetTexture("_EmoteTex", variables.emotionTexure);
     }
     if (variables.colorTexture != null)
     {
         emotivePropertyBlock.SetTexture("_ColorTex", variables.colorTexture);
     }
     emotivePropertyBlock.SetColor("_ColorTint", variables.tint);
     emotivePropertyBlock.SetFloat("_ColorXSpeed", variables.colorXSpeed);
     emotivePropertyBlock.SetFloat("_ColorYSpeed", variables.colorZSpeed);
     if (variables.displTexture != null)
     {
         emotivePropertyBlock.SetTexture("_DispTex", variables.displTexture);
     }
     emotivePropertyBlock.SetFloat("_Displacement", variables.displacement);
     emotivePropertyBlock.SetFloat("_DispSpeed", variables.displYSpeed);
     emotivePropertyBlock.SetFloat("_DispXSpeed", variables.displXSpeed);
     emotivePropertyBlock.SetFloat("_DispYSpeed", variables.displZSpeed);
     if (emotiveRenderer != null)
     {
         emotiveRenderer.SetPropertyBlock(emotivePropertyBlock);
     }
     else if (emotiveRendererSkinned != null)
     {
         emotiveRendererSkinned.SetPropertyBlock(emotivePropertyBlock);
     }
 }
Example #18
0
    // Update is called once per frame
    void Update()
    {
        // Animate the texture
        float textureTime = Mathf.Sin(Time.time * textureSpeed) * 0.5f + 0.5f;
        float textureStep = 1.0f / m_Textures.Count;

        Texture2D texture = null;

        for (int i = 0; i < m_Textures.Count; i++)
        {
            if (textureTime < textureStep * (i + 1))
            {
                texture = m_Textures[i];
                break;
            }
        }

        texture = texture ? texture : Texture2D.blackTexture;
        m_PropertyBlock.SetTexture("_MainTex", texture);
        m_PropertyBlock.SetTexture("_ShadowColor1st", texture);
        m_PropertyBlock.SetTexture("_ShadowColor2nd", texture);

        // Animate the color
        float colorTime = Mathf.Sin(Time.time * colorSpeed) * 0.5f + 0.5f;

        Color color = m_ColorGradient.Evaluate(colorTime);

        m_PropertyBlock.SetColor("_Color", color);
        m_PropertyBlock.SetColor("_ShadowColor1st", color);
        m_PropertyBlock.SetColor("_ShadowColor2nd", color);

        if (m_MeshRenderer)
        {
            m_MeshRenderer.SetPropertyBlock(m_PropertyBlock);
        }
    }
Example #19
0
    private void UpdateOutline()
    {
        if (meshRenderer == null)
        {
            return;
        }

        if (mpb == null)
        {
            mpb = new MaterialPropertyBlock();
        }

        //옷색깔
        meshRenderer.GetPropertyBlock(mpb, 0);
        mpb.SetColor("_BaseColor", cloth_Color);
        mpb.SetColor("_1st_ShadeColor", cloth_Color);
        mpb.SetColor("_2st_ShadeColor", cloth_Color);
        mpb.SetColor("_Outline_Color", cloth_Color);
        meshRenderer.SetPropertyBlock(mpb, 0);

        //1번색깔
        meshRenderer.GetPropertyBlock(mpb, 1);
        mpb.SetColor("_BaseColor", base_Color1);
        mpb.SetColor("_1st_ShadeColor", base_Color1);
        mpb.SetColor("_2st_ShadeColor", base_Color1);
        mpb.SetColor("_Outline_Color", base_Color1);
        meshRenderer.SetPropertyBlock(mpb, 1);
        meshRenderer.GetPropertyBlock(mpb, 5);
        mpb.SetColor("_BaseColor", base_Color1);
        mpb.SetColor("_1st_ShadeColor", base_Color1);
        mpb.SetColor("_2st_ShadeColor", base_Color1);
        mpb.SetColor("_Outline_Color", base_Color1);
        meshRenderer.SetPropertyBlock(mpb, 5);

        //2번색깔
        meshRenderer.GetPropertyBlock(mpb, 2);
        mpb.SetColor("_BaseColor", base_Color2);
        mpb.SetColor("_1st_ShadeColor", base_Color2);
        mpb.SetColor("_2st_ShadeColor", base_Color2);
        mpb.SetColor("_Outline_Color", base_Color2);
        meshRenderer.SetPropertyBlock(mpb, 2);
        meshRenderer.GetPropertyBlock(mpb, 6);
        mpb.SetColor("_BaseColor", base_Color2);
        mpb.SetColor("_1st_ShadeColor", base_Color2);
        mpb.SetColor("_2st_ShadeColor", base_Color2);
        mpb.SetColor("_Outline_Color", base_Color2);
        meshRenderer.SetPropertyBlock(mpb, 6);

        //얼굴
        face_Num = Mathf.Min(face_Num, face_Tex.Count - 1);
        face_Num = Mathf.Max(face_Num, 0);
        if (face_Num >= 0)
        {
            meshRenderer.GetPropertyBlock(mpb, 1);
            mpb.SetTexture("_MainTex", face_Tex[face_Num]);
            mpb.SetTexture("_1st_ShadeMap", face_Tex[face_Num]);
            mpb.SetTexture("_2st_ShadeMap", face_Tex[face_Num]);
            meshRenderer.SetPropertyBlock(mpb, 1);
            meshRenderer.GetPropertyBlock(mpb, 2);
            mpb.SetTexture("_MainTex", face_Tex[face_Num]);
            mpb.SetTexture("_1st_ShadeMap", face_Tex[face_Num]);
            mpb.SetTexture("_2st_ShadeMap", face_Tex[face_Num]);
            meshRenderer.SetPropertyBlock(mpb, 2);
        }

        //입
        mouth_Num = Mathf.Min(mouth_Num, mouth_Tex.Count - 1);
        mouth_Num = Mathf.Max(mouth_Num, 0);
        if (mouth_Num >= 0)
        {
            meshRenderer.GetPropertyBlock(mpb, 8);
            mpb.SetTexture("_MainTex", mouth_Tex[mouth_Num]);
            mpb.SetTexture("_1st_ShadeMap", mouth_Tex[mouth_Num]);
            mpb.SetTexture("_2st_ShadeMap", mouth_Tex[mouth_Num]);
            meshRenderer.SetPropertyBlock(mpb, 8);
        }

        //옷
        cloth_Num = Mathf.Min(cloth_Num, cloth_Tex.Count - 1);
        cloth_Num = Mathf.Max(cloth_Num, 0);
        if (cloth_Num >= 0)
        {
            meshRenderer.GetPropertyBlock(mpb, 0);
            mpb.SetTexture("_MainTex", cloth_Tex[cloth_Num]);
            mpb.SetTexture("_1st_ShadeMap", cloth_Tex[cloth_Num]);
            mpb.SetTexture("_2st_ShadeMap", cloth_Tex[cloth_Num]);
            meshRenderer.SetPropertyBlock(mpb, 0);
        }
    }
Example #20
0
//	void Update()
//	{
//	}

    void LateUpdate()
    {
        if (null == PropertyMaterial)
        {
            PropertyMaterial = new MaterialPropertyBlock();

            IDMaterialMainTexture   = Shader.PropertyToID("_MainTex");
            IDMaterialRectangleCell = Shader.PropertyToID("_CellRectangle");
            IDMaterialPivotCell     = Shader.PropertyToID("_CellPivot_LocalScale");
        }

        /* MEMO: "SpriteRenderer", "SpriteMask" and "SkinnedMeshRenderer" do not coexist. */
        int sortingOrder       = 0;
        int sortingOffsetParts = 1;

        if (null != PartsRoot)
        {
            sortingOrder       = PartsRoot.SortingOrder;
            sortingOffsetParts = PartsRoot.SortingOffsetPartsDraw;
            if (0 >= sortingOffsetParts)
            {
                sortingOffsetParts = 1;
            }
        }
#if UNITY_2017_1_OR_NEWER
        int sortingOrderBase = sortingOrder;
#else
#endif
        sortingOrder += ((int)OrderInLayer) * sortingOffsetParts;

        /* Sprite (SpriteRenderer) */
        if (null != InstanceSpriteRenderer)
        {
            /* Priority Set */
            if (OrderInLayerPrevious != sortingOrder)
            {
                InstanceSpriteRenderer.sortingOrder = sortingOrder;
                OrderInLayerPrevious = sortingOrder;
            }

            if (null != PropertyMaterial)
            {
                InstanceSpriteRenderer.GetPropertyBlock(PropertyMaterial);

                /* Cell Set */
                if (CellPrevious != Cell)
                {
                    /* MEMO: Not enough to just set cell to "SpriteRenderer". (Need to set texture to shader) */
                    InstanceSpriteRenderer.sprite = Cell;
                    PropertyMaterial.SetTexture(IDMaterialMainTexture, Cell.texture);

                    Vector4 temp;
                    Rect    rectangleCell = Cell.rect;
                    temp.x = rectangleCell.xMin;
                    temp.y = rectangleCell.yMin;
                    temp.z = rectangleCell.width;
                    temp.w = rectangleCell.height;
                    PropertyMaterial.SetVector(IDMaterialRectangleCell, temp);

                    /* MEMO: Since "LocalScale" is stored together in "_CellPivot_LocalScale", overwrite value set by animation. */
                    temp = PropertyMaterial.GetVector(IDMaterialPivotCell);
                    Vector2 pivot = Cell.pivot;
                    temp.x = pivot.x;
                    temp.y = rectangleCell.height - pivot.y;
                    PropertyMaterial.SetVector(IDMaterialPivotCell, temp);

                    CellPrevious = Cell;
                }

                InstanceSpriteRenderer.SetPropertyBlock(PropertyMaterial);
            }

            return;
        }

        /* Mask (SpriteMask) */
#if UNITY_2017_1_OR_NEWER
        if (null != InstanceSpriteMask)
        {
            if (OrderInLayerPrevious != sortingOrder)
            {
                InstanceSpriteMask.frontSortingOrder = sortingOrder;
                InstanceSpriteMask.backSortingOrder  = sortingOrderBase - PartsRoot.SortingOffsetPartsDraw;
                OrderInLayerPrevious = sortingOrder;
            }

            if (null != Cell)
            {
                InstanceSpriteMask.sprite = Cell;
                Cell = null;
            }

            return;
        }
#else
        /* MEMO: Can not use "SpriteMask" in Unity5.6 or earlier.                               */
        /*       (For "Nintendo Switch" for the time being, corresponds to Unity5.6 or earlier) */
#endif

        /* Mesh (SkinnedMeshRenderer) */
        if (null != InstanceSkinnedMeshRenderer)
        {
            if (OrderInLayerPrevious != sortingOrder)
            {
                InstanceSkinnedMeshRenderer.sortingOrder = sortingOrder;
                OrderInLayerPrevious = sortingOrder;
            }

            if (CellMeshPrevious != CellMesh)
            {
                if (null == InstanceCellMesh)
                {
                    InstanceCellMesh = new Mesh();
                    if (null == InstanceCellMesh)
                    {                           /* Error */
                        return;
                    }
                }

                /* Re-Set Mesh */
                InstanceCellMesh.Clear();
                InstanceCellMesh.name        = CellMesh.name;
                InstanceCellMesh.vertices    = CellMesh.vertices;
                InstanceCellMesh.uv          = CellMesh.uv;
                InstanceCellMesh.triangles   = CellMesh.triangles;
                InstanceCellMesh.boneWeights = CellMesh.boneWeights;
                InstanceCellMesh.bindposes   = TableMatrixBindPose;

                InstanceSkinnedMeshRenderer.sharedMesh = InstanceCellMesh;

                CellMeshPrevious = CellMesh;
            }

            if (TextureMeshPrevious != TextureMesh)
            {
                InstanceSkinnedMeshRenderer.GetPropertyBlock(PropertyMaterial);

                PropertyMaterial.SetTexture(IDMaterialMainTexture, TextureMesh);

                InstanceSkinnedMeshRenderer.SetPropertyBlock(PropertyMaterial);

                TextureMeshPrevious = TextureMesh;
            }

            return;
        }

        /* Mesh (SkinnedMeshRenderer) */
        if (null != InstanceMeshRenderer)
        {
            if (OrderInLayerPrevious != sortingOrder)
            {
                InstanceMeshRenderer.sortingOrder = sortingOrder;
                OrderInLayerPrevious = sortingOrder;
            }

            if (CellMeshPrevious != CellMesh)
            {
                if (null == InstanceCellMesh)
                {
                    InstanceCellMesh = new Mesh();
                    if (null == InstanceCellMesh)
                    {                           /* Error */
                        return;
                    }
                }

                /* Re-Set Mesh */
                InstanceCellMesh.Clear();
                InstanceCellMesh.name      = CellMesh.name;
                InstanceCellMesh.vertices  = CellMesh.vertices;
                InstanceCellMesh.uv        = CellMesh.uv;
                InstanceCellMesh.triangles = CellMesh.triangles;
//				InstanceCellMesh.boneWeights =
//				InstanceCellMesh.bindposes =

                InstanceMeshFilter.sharedMesh = InstanceCellMesh;

                CellMeshPrevious = CellMesh;
            }

            if (TextureMeshPrevious != TextureMesh)
            {
                InstanceMeshRenderer.GetPropertyBlock(PropertyMaterial);

                PropertyMaterial.SetTexture(IDMaterialMainTexture, TextureMesh);

                InstanceMeshRenderer.SetPropertyBlock(PropertyMaterial);

                TextureMeshPrevious = TextureMesh;
            }

            return;
        }
    }
Example #21
0
 private void InitializePropertyBlock()
 {
     _materialProperty = new MaterialPropertyBlock();
     _skinnedMeshRendererOne.SetPropertyBlock(_materialProperty);
     _skinnedMeshRendererTwo.SetPropertyBlock(_materialProperty);
 }
    private void UpdateOutline()
    {
        if (meshRenderer == null)
        {
            return;
        }

        if (mpb == null)
        {
            mpb = new MaterialPropertyBlock();
        }

        //머리 색상
        meshRenderer.GetPropertyBlock(mpb, 0);
        mpb.SetColor("_Color", hair_Color);
        mpb.SetColor("_ColorDim", hair_Color * 1.5f);
        mpb.SetColor("_ColorDimExtra", hair_Color);
        meshRenderer.SetPropertyBlock(mpb, 0);

        //피부 색상
        meshRenderer.GetPropertyBlock(mpb, 1);
        mpb.SetColor("_Color", skin_Color);
        mpb.SetColor("_ColorDim", skin_Color * skin_Color);
        mpb.SetColor("_ColorDimExtra", skin_Color * skin_Color * skin_Color);
        meshRenderer.SetPropertyBlock(mpb, 1);
        meshRenderer.GetPropertyBlock(mpb, 2);
        mpb.SetColor("_Color", skin_Color * 1.2f);
        mpb.SetColor("_ColorDim", skin_Color * skin_Color * 1.2f);
        mpb.SetColor("_ColorDimExtra", skin_Color * skin_Color * skin_Color * 1.2f);
        meshRenderer.SetPropertyBlock(mpb, 2);
        meshRenderer.GetPropertyBlock(mpb, 3);
        mpb.SetColor("_Color", skin_Color * 1.2f);
        mpb.SetColor("_ColorDim", skin_Color * skin_Color * 1.2f);
        mpb.SetColor("_ColorDimExtra", skin_Color * skin_Color * skin_Color * 1.2f);
        meshRenderer.SetPropertyBlock(mpb, 3);

        //옷 색상
        meshRenderer.GetPropertyBlock(mpb, 4);
        mpb.SetColor("_Color", cloth_Color);
        mpb.SetColor("_ColorDim", cloth_Color * cloth_Color);
        mpb.SetColor("_ColorDimExtra", cloth_Color * cloth_Color * cloth_Color);
        meshRenderer.SetPropertyBlock(mpb, 4);
        meshRenderer.GetPropertyBlock(mpb, 7);
        mpb.SetColor("_Color", cloth_Color * 1.5f);
        mpb.SetColor("_ColorDim", cloth_Color * cloth_Color * 1.5f);
        mpb.SetColor("_ColorDimExtra", cloth_Color * cloth_Color * cloth_Color * 1.5f);
        meshRenderer.SetPropertyBlock(mpb, 7);

        //눈
        meshRenderer.GetPropertyBlock(mpb, 3);
        mpb.SetTexture("_MainTex", eye_Tex[eye_Num]);
        meshRenderer.SetPropertyBlock(mpb, 3);

        //입
        meshRenderer.GetPropertyBlock(mpb, 2);
        mpb.SetTexture("_MainTex", mouth_Tex[mouth_Num]);
        meshRenderer.SetPropertyBlock(mpb, 2);

        for (int i = 0; i < 10; i++)
        {
            Color temp;
            //기타
            meshRenderer.GetPropertyBlock(mpb, i);
            temp = mpb.GetColor("_Color");
            temp = new Color(temp.r, temp.g, temp.b, alpha ? 0 : 1);
            mpb.SetColor("_Color", temp);
            temp = mpb.GetColor("_ColorDim");
            temp = new Color(temp.r, temp.g, temp.b, alpha ? 0 : 1);
            mpb.SetColor("_ColorDim", temp);
            temp = mpb.GetColor("_ColorDimExtra");
            temp = new Color(temp.r, temp.g, temp.b, alpha ? 0 : 1);
            mpb.SetColor("_ColorDimExtra", temp);
            meshRenderer.SetPropertyBlock(mpb, i);
        }
    }