How can I switch between rendering modes of standard shader?










2















The shader:



Shader "Standard"
{
Properties

[LM_Albedo] [LM_Transparency] _Color("Color", Color) = (1,1,1,1)
[LM_MasterTilingOffset] [LM_Albedo] _MainTex("Albedo", 2D) = "white"

[LM_TransparencyCutOff] _AlphaTestRef("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

[LM_Glossiness] _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.0
[LM_Metallic] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
[LM_Metallic] [LM_Glossiness] _MetallicGlossMap("Metallic", 2D) = "white"

_BumpScale("Scale", Float) = 1.0
[LM_NormalMap] _BumpMap("Normal Map", 2D) = "bump"

_Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
_ParallaxMap ("Height Map", 2D) = "black"

_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion", 2D) = "white"

[LM_Emission] _EmissionColor("Color", Color) = (0,0,0)
[LM_Emission] _EmissionMap("Emission", 2D) = "white"

_DetailMask("Detail Mask", 2D) = "white"

_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey"
_DetailNormalMapScale("Scale", Float) = 1.0
_DetailNormalMap("Normal Map", 2D) = "bump"

[KeywordEnum(UV1, UV2)] _UVSec ("UV Set for secondary textures", Float) = 0

// UI-only data
[KeywordEnum(None, Realtime, Baked)] _Lightmapping ("GI", Int) = 1
[HideInInspector] _EmissionScaleUI("Scale", Float) = 1.0
[HideInInspector] _EmissionColorUI("Color", Color) = (0,0,0)
[HideInInspector] _EmissionColorWithMapUI("Color", Color) = (1,1,1)

// Blending state
[HideInInspector] _Mode ("__mode", Float) = 0.0
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
[HideInInspector] _ZWrite ("__zw", Float) = 1.0



It have 4 modes: Opaque, Cutout, Fade, Transparent
I want to switch between this 4 modes and affecting the specific gameobject shader rendering modes in the hierarchy using a button.



Each click on the button will switch to the next mode.



And in EditorWindow



The script:



using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class ChangeShaderRenderingModes : EditorWindow

public enum BlendMode

Opaque,
Cutout,
Fade,
Transparent


[MenuItem("Tools/Change Rendering Modes")]
public static void ShowWindow()

GetWindow<ChangeShaderRenderingModes>("ChangeRenderingModes");


private void OnGUI()

if(GUI.Button(new Rect(50,50,50,50), "Switch Mode"))

var objects = Selection.objects;





I'm not sure how to make the switching and accessing the shader parameters.










share|improve this question




























    2















    The shader:



    Shader "Standard"
    {
    Properties

    [LM_Albedo] [LM_Transparency] _Color("Color", Color) = (1,1,1,1)
    [LM_MasterTilingOffset] [LM_Albedo] _MainTex("Albedo", 2D) = "white"

    [LM_TransparencyCutOff] _AlphaTestRef("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

    [LM_Glossiness] _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.0
    [LM_Metallic] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
    [LM_Metallic] [LM_Glossiness] _MetallicGlossMap("Metallic", 2D) = "white"

    _BumpScale("Scale", Float) = 1.0
    [LM_NormalMap] _BumpMap("Normal Map", 2D) = "bump"

    _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
    _ParallaxMap ("Height Map", 2D) = "black"

    _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
    _OcclusionMap("Occlusion", 2D) = "white"

    [LM_Emission] _EmissionColor("Color", Color) = (0,0,0)
    [LM_Emission] _EmissionMap("Emission", 2D) = "white"

    _DetailMask("Detail Mask", 2D) = "white"

    _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey"
    _DetailNormalMapScale("Scale", Float) = 1.0
    _DetailNormalMap("Normal Map", 2D) = "bump"

    [KeywordEnum(UV1, UV2)] _UVSec ("UV Set for secondary textures", Float) = 0

    // UI-only data
    [KeywordEnum(None, Realtime, Baked)] _Lightmapping ("GI", Int) = 1
    [HideInInspector] _EmissionScaleUI("Scale", Float) = 1.0
    [HideInInspector] _EmissionColorUI("Color", Color) = (0,0,0)
    [HideInInspector] _EmissionColorWithMapUI("Color", Color) = (1,1,1)

    // Blending state
    [HideInInspector] _Mode ("__mode", Float) = 0.0
    [HideInInspector] _SrcBlend ("__src", Float) = 1.0
    [HideInInspector] _DstBlend ("__dst", Float) = 0.0
    [HideInInspector] _ZWrite ("__zw", Float) = 1.0



    It have 4 modes: Opaque, Cutout, Fade, Transparent
    I want to switch between this 4 modes and affecting the specific gameobject shader rendering modes in the hierarchy using a button.



    Each click on the button will switch to the next mode.



    And in EditorWindow



    The script:



    using System.Collections;
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEngine;

    public class ChangeShaderRenderingModes : EditorWindow

    public enum BlendMode

    Opaque,
    Cutout,
    Fade,
    Transparent


    [MenuItem("Tools/Change Rendering Modes")]
    public static void ShowWindow()

    GetWindow<ChangeShaderRenderingModes>("ChangeRenderingModes");


    private void OnGUI()

    if(GUI.Button(new Rect(50,50,50,50), "Switch Mode"))

    var objects = Selection.objects;





    I'm not sure how to make the switching and accessing the shader parameters.










    share|improve this question


























      2












      2








      2








      The shader:



      Shader "Standard"
      {
      Properties

      [LM_Albedo] [LM_Transparency] _Color("Color", Color) = (1,1,1,1)
      [LM_MasterTilingOffset] [LM_Albedo] _MainTex("Albedo", 2D) = "white"

      [LM_TransparencyCutOff] _AlphaTestRef("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

      [LM_Glossiness] _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.0
      [LM_Metallic] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
      [LM_Metallic] [LM_Glossiness] _MetallicGlossMap("Metallic", 2D) = "white"

      _BumpScale("Scale", Float) = 1.0
      [LM_NormalMap] _BumpMap("Normal Map", 2D) = "bump"

      _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
      _ParallaxMap ("Height Map", 2D) = "black"

      _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
      _OcclusionMap("Occlusion", 2D) = "white"

      [LM_Emission] _EmissionColor("Color", Color) = (0,0,0)
      [LM_Emission] _EmissionMap("Emission", 2D) = "white"

      _DetailMask("Detail Mask", 2D) = "white"

      _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey"
      _DetailNormalMapScale("Scale", Float) = 1.0
      _DetailNormalMap("Normal Map", 2D) = "bump"

      [KeywordEnum(UV1, UV2)] _UVSec ("UV Set for secondary textures", Float) = 0

      // UI-only data
      [KeywordEnum(None, Realtime, Baked)] _Lightmapping ("GI", Int) = 1
      [HideInInspector] _EmissionScaleUI("Scale", Float) = 1.0
      [HideInInspector] _EmissionColorUI("Color", Color) = (0,0,0)
      [HideInInspector] _EmissionColorWithMapUI("Color", Color) = (1,1,1)

      // Blending state
      [HideInInspector] _Mode ("__mode", Float) = 0.0
      [HideInInspector] _SrcBlend ("__src", Float) = 1.0
      [HideInInspector] _DstBlend ("__dst", Float) = 0.0
      [HideInInspector] _ZWrite ("__zw", Float) = 1.0



      It have 4 modes: Opaque, Cutout, Fade, Transparent
      I want to switch between this 4 modes and affecting the specific gameobject shader rendering modes in the hierarchy using a button.



      Each click on the button will switch to the next mode.



      And in EditorWindow



      The script:



      using System.Collections;
      using System.Collections.Generic;
      using UnityEditor;
      using UnityEngine;

      public class ChangeShaderRenderingModes : EditorWindow

      public enum BlendMode

      Opaque,
      Cutout,
      Fade,
      Transparent


      [MenuItem("Tools/Change Rendering Modes")]
      public static void ShowWindow()

      GetWindow<ChangeShaderRenderingModes>("ChangeRenderingModes");


      private void OnGUI()

      if(GUI.Button(new Rect(50,50,50,50), "Switch Mode"))

      var objects = Selection.objects;





      I'm not sure how to make the switching and accessing the shader parameters.










      share|improve this question
















      The shader:



      Shader "Standard"
      {
      Properties

      [LM_Albedo] [LM_Transparency] _Color("Color", Color) = (1,1,1,1)
      [LM_MasterTilingOffset] [LM_Albedo] _MainTex("Albedo", 2D) = "white"

      [LM_TransparencyCutOff] _AlphaTestRef("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

      [LM_Glossiness] _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.0
      [LM_Metallic] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
      [LM_Metallic] [LM_Glossiness] _MetallicGlossMap("Metallic", 2D) = "white"

      _BumpScale("Scale", Float) = 1.0
      [LM_NormalMap] _BumpMap("Normal Map", 2D) = "bump"

      _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
      _ParallaxMap ("Height Map", 2D) = "black"

      _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
      _OcclusionMap("Occlusion", 2D) = "white"

      [LM_Emission] _EmissionColor("Color", Color) = (0,0,0)
      [LM_Emission] _EmissionMap("Emission", 2D) = "white"

      _DetailMask("Detail Mask", 2D) = "white"

      _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey"
      _DetailNormalMapScale("Scale", Float) = 1.0
      _DetailNormalMap("Normal Map", 2D) = "bump"

      [KeywordEnum(UV1, UV2)] _UVSec ("UV Set for secondary textures", Float) = 0

      // UI-only data
      [KeywordEnum(None, Realtime, Baked)] _Lightmapping ("GI", Int) = 1
      [HideInInspector] _EmissionScaleUI("Scale", Float) = 1.0
      [HideInInspector] _EmissionColorUI("Color", Color) = (0,0,0)
      [HideInInspector] _EmissionColorWithMapUI("Color", Color) = (1,1,1)

      // Blending state
      [HideInInspector] _Mode ("__mode", Float) = 0.0
      [HideInInspector] _SrcBlend ("__src", Float) = 1.0
      [HideInInspector] _DstBlend ("__dst", Float) = 0.0
      [HideInInspector] _ZWrite ("__zw", Float) = 1.0



      It have 4 modes: Opaque, Cutout, Fade, Transparent
      I want to switch between this 4 modes and affecting the specific gameobject shader rendering modes in the hierarchy using a button.



      Each click on the button will switch to the next mode.



      And in EditorWindow



      The script:



      using System.Collections;
      using System.Collections.Generic;
      using UnityEditor;
      using UnityEngine;

      public class ChangeShaderRenderingModes : EditorWindow

      public enum BlendMode

      Opaque,
      Cutout,
      Fade,
      Transparent


      [MenuItem("Tools/Change Rendering Modes")]
      public static void ShowWindow()

      GetWindow<ChangeShaderRenderingModes>("ChangeRenderingModes");


      private void OnGUI()

      if(GUI.Button(new Rect(50,50,50,50), "Switch Mode"))

      var objects = Selection.objects;





      I'm not sure how to make the switching and accessing the shader parameters.







      c# unity3d






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 '18 at 23:52









      DeanOC

      5,42263045




      5,42263045










      asked Nov 10 '18 at 23:44









      Benzi AvrumiBenzi Avrumi

      39110




      39110






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244525%2fhow-can-i-switch-between-rendering-modes-of-standard-shader%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244525%2fhow-can-i-switch-between-rendering-modes-of-standard-shader%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Edmonton

          Crossroads (UK TV series)