Skip to content

Instantly share code, notes, and snippets.

@quizcanners
Last active September 17, 2018 09:08
Show Gist options
  • Save quizcanners/b80c32594c650b394570ace34bec0216 to your computer and use it in GitHub Desktop.
Save quizcanners/b80c32594c650b394570ace34bec0216 to your computer and use it in GitHub Desktop.
PEGI wrapper for EditorGUILayout
// How it would have been written with standard functions. Class palced inside Editor Folder.
EditorGUILayout.BeginHorizontal();
int before = target.transparency;
target.transparency = EditorGUILayout.IntField("Transparency:", target.transparency);
if (target.transparency != before)
target.RecalculateShaderParameters();
EditorGUILayout.EndHorizontal();
// How the same code is written with PEGI wrapper, function is placed inside class.
if ("Transparency:".edit(ref transparency).nl())
RecalculateShaderParameters();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment