本文整理汇总了C#中UnityEngine.GUIContent类的典型用法代码示例。如果您正苦于以下问题:C# GUIContent类的具体用法?C# GUIContent怎么用?C# GUIContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GUIContent类属于UnityEngine命名空间,在下文中一共展示了GUIContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (IsEnabled) {
var propertyType = fieldInfo.FieldType;
var target = fiSerializedPropertyUtility.GetTarget(property);
var metadata = fiSerializedPropertyUtility.GetMetadata(property);
var editor = PropertyEditor.Get(propertyType, fieldInfo).FirstEditor;
if (property.prefabOverride) fiUnityInternalReflection.SetBoldDefaultFont(true);
var savedHierarchyMode = EditorGUIUtility.hierarchyMode;
EditorGUIUtility.hierarchyMode = true;
EditorGUI.BeginChangeCheck();
target = editor.Edit(position, label, target, metadata);
if (EditorGUI.EndChangeCheck()) {
fiSerializedPropertyUtility.WriteTarget(property, target);
EditorUtility.SetDirty(property.serializedObject.targetObject);
}
EditorGUIUtility.hierarchyMode = savedHierarchyMode;
if (property.prefabOverride) fiUnityInternalReflection.SetBoldDefaultFont(false);
fiSerializedPropertyUtility.RevertPrefabContextMenu(position, property);
return;
}
EditorGUI.PropertyField(position, property, label);
}
示例2: GetPropertyHeight
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = base.GetPropertyHeight(property, label);
CheckRequiredComponents(property.GetValue<EntityBehaviour>());
return height;
}
示例3: OnGUI
public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) {
SerializedProperty selection = prop.FindPropertyRelative("selection");
SerializedProperty gameObject = prop.FindPropertyRelative("gameObject");
CacheOwnerGameObject(prop.serializedObject);
// draw the enum popup Field
int oldEnumIndex = selection.enumValueIndex;
EditorGUI.PropertyField(
GetRectforRow(pos,0),
selection,new GUIContent("Target"),true);
if (oldEnumIndex !=selection.enumValueIndex)
{
if (selection.enumValueIndex==1)
{
gameObject.objectReferenceValue = ownerGameObject;
}
}
if (selection.enumValueIndex==1)
{
EditorGUI.indentLevel++;
EditorGUI.PropertyField(
GetRectforRow(pos,1),
gameObject,new GUIContent("Game Object"),true);
}
}
示例4: IntField
/** Draws an integer field */
public int IntField (GUIContent label, int value, int offset, int adjust, out Rect r) {
GUIStyle intStyle = EditorStyles.numberField;
EditorGUILayoutx.BeginIndent ();
Rect r1 = GUILayoutUtility.GetRect (label,intStyle);
Rect r2 = GUILayoutUtility.GetRect (new GUIContent (value.ToString ()),intStyle);
EditorGUILayoutx.EndIndent();
r2.width += (r2.x-r1.x);
r2.x = r1.x+offset;
r2.width -= offset+offset+adjust;
r = new Rect ();
r.x = r2.x+r2.width;
r.y = r1.y;
r.width = offset;
r.height = r1.height;
GUI.SetNextControlName ("IntField_"+label.text);
value = EditorGUI.IntField (r2,"",value);
bool on = GUI.GetNameOfFocusedControl () == "IntField_"+label.text;
if (Event.current.type == EventType.Repaint) {
intStyle.Draw (r1,label,false,false,false,on);
}
return value;
}
示例5: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
{
if (EditorGUI.PropertyField(position, property))
{
EditorGUILayout.PropertyField(property.FindPropertyRelative("type"));
switch (property.FindPropertyRelative("type").enumValueIndex)
{
case 0: // None
break;
case 1: // Sphere
EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
break;
case 2: // Box
EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("size"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
break;
case 3: // Capsule
EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("direction"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("height"));
EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
break;
}
}
}
EditorGUI.EndProperty();
}
示例6: GetPropertyHeightSafe
internal float GetPropertyHeightSafe(SerializedProperty property, GUIContent label)
{
ScriptAttributeUtility.s_DrawerStack.Push(this);
float propertyHeight = this.GetPropertyHeight(property, label);
ScriptAttributeUtility.s_DrawerStack.Pop();
return propertyHeight;
}
示例7: GetPropertyHeight
public override float GetPropertyHeight(SerializedProperty _property, GUIContent _label)
{
if (_property.isArray)
return EditorGUI.GetPropertyHeight(_property);
return EditorGUI.GetPropertyHeight(_property) + kButtonHeight + kOffset;
}
示例8: Foldout
public static bool Foldout(bool open, GUIContent header, Action content)
{
if (foldoutStyle == null)
{
foldoutStyle = new GUIStyle(GUI.skin.FindStyle("ShurikenModuleBg"));
foldoutStyle.padding = new RectOffset(10, 10, 10, 10);
headerStyle = new GUIStyle(GUI.skin.FindStyle("ShurikenModuleTitle"));
headerStyle.contentOffset = new Vector2(3, -2);
}
GUILayout.BeginVertical("ShurikenEffectBg", GUILayout.MinHeight(1f));
open = GUI.Toggle(GUILayoutUtility.GetRect(0, 16), open, header, headerStyle);
if (open)
{
GUILayout.BeginVertical(foldoutStyle);
content();
GUILayout.EndVertical();
}
GUILayout.EndVertical();
return open;
}
示例9: OnGUI
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
{
EditorGUI.BeginProperty(position, label, prop);
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text, (attribute as SingleLineAttribute).Tooltip));
const float labelWidth = 32.0f;
float widthAvailable = position.width - (labelWidth * 2.0f);
float textFieldWidth = widthAvailable * 0.5f;
switch (prop.type)
{
case "RangeOfIntegers":
DrawRangeField(position, labelWidth, textFieldWidth, prop, false);
break;
case "RangeOfFloats":
DrawRangeField(position, labelWidth, textFieldWidth, prop, true);
break;
default:
EditorGUI.HelpBox(position, "[Compact] doesn't work with type '" + prop.type + "'", MessageType.Error);
break;
}
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
示例10: GetPropertyHeight
/// <summary>
/// Gets the total height of this editor.
/// </summary>
/// <param name="property">Property to get the total height of the editor for.</param>
/// <param name="label">The parameter is not used.</param>
/// <returns>Total height of this editor.</returns>
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
SerializedProperty sourceProperty = this.GetSourceProperty(property);
SerializedProperty memberProperty = this.GetMemberProperty(property);
return EditorGUI.GetPropertyHeight(sourceProperty) + EditorGUI.GetPropertyHeight(memberProperty);
}
示例11: GetPropertyHeight
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = 0f; // since no stylesheet title (yet)
/**
* NOTE: This is weird (the following 3 lines
* I commented out these on 20131129 because eDrivenGuiStyleSheet didn't render properly
* (measured height of each declaration was zero)
* It's weird because it worked fine with eDrivenStyleSheet and they both have the same base class
* */
/*if (!property.isExpanded)
{
return height;
}*/
SerializedProperty declarations = property.FindPropertyRelative("Declarations");
int size = declarations.arraySize;
if (size == 0)
{
return height; // +16f;
}
for (int i = 0; i < size; i++)
{
height += EditorGUI.GetPropertyHeight(declarations.GetArrayElementAtIndex(i));
}
// gaps
if (size > 0)
height += VerticalGap*(size - 1);
return height;
}
示例12: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (list == null) initList(property, label);
list.serializedProperty = property.FindPropertyRelative("tagList");
list.DoList(position);
}
示例13: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var left = position; left.xMax -= 40;
var right = position; right.xMin = left.xMax + 2;
EditorGUI.PropertyField(left, property);
if (GUI.Button(right, "List") == true)
{
var menu = new GenericMenu();
if (LeanLocalization.Instance != null)
{
for (var j = 0; j < LeanLocalization.Instance.Languages.Count; j++)
{
var language = LeanLocalization.Instance.Languages[j];
menu.AddItem(new GUIContent(language), property.stringValue == language, () => { property.stringValue = language; property.serializedObject.ApplyModifiedProperties(); });
}
}
if (menu.GetItemCount() > 0)
{
menu.DropDown(right);
}
else
{
Debug.LogWarning("Your scene doesn't contain any languages, so the language name list couldn't be created.");
}
}
}
示例14: OnEnable
private void OnEnable()
{
_inputEvents = serializedObject.FindProperty("_inputEvents");
_plusButtonContent = new GUIContent(EditorGUIUtility.Load("ol plus.png") as Texture, "Insert a new event after this one.");
_minusButtonContent = new GUIContent(EditorGUIUtility.Load("ol minus.png") as Texture, "Delete this event.");
_eventManager = (InputEventManager)target;
}
示例15: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
rtpc = property.GetValue<AudioRTPC>();
Begin(position, property, label);
string rtpcName = string.Format("{4}{0} | {1} [{2}, {3}]", rtpc.Name, rtpc.Type, rtpc.MinValue, rtpc.MaxValue, rtpc.Scope == AudioRTPC.RTPCScope.Global ? "*" : "");
PropertyField(property, rtpcName.ToGUIContent(), false);
if (property.isExpanded)
{
EditorGUI.indentLevel++;
PropertyField(property.FindPropertyRelative("Scope"), GUIContent.none);
PropertyField(property.FindPropertyRelative("Name"));
PropertyField(property.FindPropertyRelative("Type"));
PropertyField(property.FindPropertyRelative("MinValue"));
PropertyField(property.FindPropertyRelative("MaxValue"));
PropertyField(property.FindPropertyRelative("Curve"));
EditorGUI.indentLevel--;
}
End();
}