Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to change the material of gameObject efficiently in runtime?

Discussion in 'Scripting' started by Bagazi, Apr 11, 2021.

  1. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    upload_2021-4-11_10-49-42.png
    I use this to change the material, it works. But I am a little worried about the Resources.Load , cause I need to call this function frequently.Will it slow the game,and is there any alternatvie with
    more efficient?

    Ps: cameraMaterials[index] is path in string
     
  2. chengwang2077

    chengwang2077

    Joined:
    Nov 23, 2019
    Posts:
    131
    It seems that resources.load will not be loaded repeatedly
     
    Bagazi likes this.