Skip to content

Instantly share code, notes, and snippets.

@kirevdokimov
Last active August 28, 2017 13:23
Show Gist options
  • Save kirevdokimov/995cfc7b8b3bbfa07791405191fc426b to your computer and use it in GitHub Desktop.
Save kirevdokimov/995cfc7b8b3bbfa07791405191fc426b to your computer and use it in GitHub Desktop.
456
======================================================================================================
ObjectField
var newMaterial = (Material) EditorGUILayout.ObjectField("Material", currentMaterial, typeof(Material),false);
======================================================================================================
static void ShowReadonlyIntField(string name, int value){
EditorGUILayout.BeginHorizontal();
GUILayout.Label(name, GUILayout.Width(EditorGUIUtility.labelWidth));
GUI.enabled = false;
EditorGUILayout.IntField(value);
GUI.enabled = true;
EditorGUILayout.EndHorizontal();
}
======================================================================================================
HelpBox
GUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.Label("Title");
GUILayout.Label("Description", EditorStyles.wordWrappedMiniLabel);
GUILayout.EndVertical();
======================================================================================================
// Позволяет менять фон кнопки (возможно и других элементов, но это нужно тестировать)
GUI.backgroundColor = Color.blue;
GUILayout.Button("X");
======================================================================================================
GUI элементам можно задавать несвойственные им стили через
EditorStyles. или GUI.skin. или можно задавать даже строками e.g. "miniButton" (но такого, думаю, лучше избегать)
void OnGUI{
bool b = GUI.Toggle(rect, value, text, GUI.skin.button);
}
======================================================================================================
Можно подписываться на события Undo Redo
Undo.undoRedoPerformed += OnUndoPerformed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment