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 get material used full keywords in runtime

Discussion in 'Shaders' started by chengyingzhilian, Apr 21, 2022.

  1. chengyingzhilian

    chengyingzhilian

    Joined:
    Oct 6, 2018
    Posts:
    8
    hi all. i want to get the material used keywords list. like the framedebugger showing.
    upload_2022-4-21_17-29-26.png

    but ,if i use material.shaderKeywords. it only return the pre-set in material and enable by code .
    upload_2022-4-21_17-31-13.png

    and i think can use
    Shader.IsKeywordEnabled("INSTANCING_ON"),but it return false. only return true to who set by code.

    is it have any idea to get the full keywords .
    or can get the enable global keyword?
    thanks!
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Hi!
    This is not possible at the moment.
     
  3. chengyingzhilian

    chengyingzhilian

    Joined:
    Oct 6, 2018
    Posts:
    8
    thanks.
    I once saw the team of Unity China show a paragraph about running games on mobile phones to collect real-time shader variantsuses a extension tool. Do not modify the unity code. Can you roughly guess how to implement to get keywords
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Yeah - there's a checkbox in player settings that enables logging when a new variant gets compiled. This log can then be parsed.