Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

myMaterialPropertyBlock.SetMatrixArray cross over data with different sized arrays

Discussion in '5.4 Beta' started by AVOlight, Dec 30, 2015.

  1. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    example
    Code (CSharp):
    1.  
    2. // gameObjectA and gameObjectB share same mesh and material
    3.     var meshA = gameObjectA.GetComponent<MeshRenderer>();
    4.     var myMaterialBlockA = new MaterialPropertyBlock();
    5.     var length = 6;
    6.     var myMatrixColorsA = GetMatrixWithRandomColors(length);
    7.     myMaterialBlockA.SetMatrixArray("Colors", myMatrixColorsA);
    8.     var meshB = gameObjectB.GetComponent<MeshRenderer>();
    9.     var myMaterialBlockB = new MaterialPropertyBlock();
    10.     length = 2;
    11.     var myMatrixColorsB = GetMatrixWithRandomColors(length);
    12.     myMaterialBlockB.SetMatrixArray("Colors", myMatrixColorsB);
    13.     meshB.SetPropertyBlock(myMaterialBlockB);
    14.  
    meshB will also get 6 colors,
    2 from myMaterialBlockB, and 4 from myMaterialBlockA

    :(
     
    Last edited: Dec 30, 2015
  2. zeroyao

    zeroyao

    Unity Technologies

    Joined:
    Mar 28, 2013
    Posts:
    169
    Looks rather curious. Could you please send us a bug report with the problematic scene attached? Thanks.
     
  3. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    i think its described here bottom of page 4