public static Texture DrawTextureFieldWithLabel(Rect rect, string label, int labelWidth, Texture field, bool required = false) { if (CanDraw == true) { if (required == true) { if (field == null) { if (CanDraw == true) { var redRect = new Rect(rect); redRect = SGT_RectHelper.ExpandPx(redRect, 1.0f, 1.0f, 1.0f, 1.0f); GUI.DrawTexture(redRect, SGT_Helper.RedTexture); } } } var labelRect = SGT_RectHelper.GetLeftPx(ref rect, labelWidth); EditorGUI.LabelField(labelRect, new GUIContent(label, string.Empty), EditorStyles.label); var newField = (Texture)EditorGUI.ObjectField(rect, field, typeof(Texture), false); FieldModified |= newField != field; field = newField; } return(field); }
private static SGT_MultiMesh MultiMeshFieldWithLabel(Rect rect, string label, int labelWidth, SGT_MultiMesh field, bool required = false) { if (CanDraw == true && field != null) { if (required == true) { if (field.ContainsSomething == false) { var redRect = new Rect(rect); redRect = SGT_RectHelper.ExpandPx(redRect, 1.0f, 1.0f, 1.0f, 1.0f); GUI.DrawTexture(redRect, SGT_Helper.RedTexture); } } var labelRect = SGT_RectHelper.GetLeftPx(ref rect, labelWidth); EditorGUI.LabelField(labelRect, new GUIContent(label, string.Empty), EditorStyles.label); var curMesh = field.GetSharedMesh(0); var newMesh = (Mesh)EditorGUI.ObjectField(rect, curMesh, typeof(Mesh), false); if (curMesh != newMesh) { field.ReplaceAll(newMesh); } } return(field); }
public static bool BeginToggleGroup(string handle, string tooltip, bool toggle) { if (CanDraw == true) { var handleRect = Reserve(fieldHeight); var toggleRect = SGT_RectHelper.GetLeftPx(ref handleRect, toggleWidth); EditorGUI.LabelField(handleRect, new GUIContent(handle, tooltip), EditorStyles.boldLabel); var newToggle = EditorGUI.Toggle(toggleRect, toggle); FieldModified |= newToggle != toggle; toggle = newToggle; } BeginIndent(toggle); return(toggle); }