#showing/hiding a property based off of a boolean?
1 messages · Page 1 of 1 (latest)
Iirc for this you need a "custom editor GUI" script
Shader Graph's importable "production ready shaders" sample has an example of the Lit shader's custom GUI
aw man i didn't wanna have to do manual scripting for such as simple thing 😭
are there any alternatives?
None that I know of
Besides just to live with all properties visible
An editor GUI editor would be nice
The way to get to it is probably like this, even without the sample
that looks like it's for HDRP, im using URP
idk if it matters, i just thought i'd point that out
oh found it
Graph Settings have "Custom Editor GUI" field which in the sample points to LitShader.cs that you can find by searching in "all" or "packages"
ye i saw that too
https://docs.unity3d.com/ScriptReference/ShaderGUI.html im using this as a reference too
i'll share my findings here when i figure it out
just for if someone happens to also have this issue
The Unity Manual helps you learn and use the Unity engine. With the Unity engine you can create 2D and 3D games, apps and experiences.
AH i did it
so first you make a boolean KEYWORD
not just a normal boolean
and by default it makes it into a branch kind of thing
in the shader gui script, i used this code
using System;
using UnityEditor;
using UnityEngine;
public class VertexColorTextureBlendEditor : ShaderGUI
{
float doesThisWork = 0f;
override public void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
base.OnGUI(materialEditor, properties);
Material targetMat = materialEditor.target as Material;
bool useMetallicMap = Array.IndexOf(targetMat.shaderKeywords, "_USEHEAVYMETALMAP_ON") != -1;
if (useMetallicMap)
doesThisWork = EditorGUILayout.FloatField("Does This Work?", doesThisWork);
}
}
and yes you gotta do this
thank you @meager apex