当前位置: 首页>>代码示例>>C#>>正文


C# GUIContent类代码示例

本文整理汇总了C#中GUIContent的典型用法代码示例。如果您正苦于以下问题:C# GUIContent类的具体用法?C# GUIContent怎么用?C# GUIContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GUIContent类属于命名空间,在下文中一共展示了GUIContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnGUI

    // Draw the property inside the given rect
    public override void OnGUI( Rect position, SerializedProperty property, GUIContent label )
    {
        // Now draw the property as a Slider or an IntSlider based on whether it’s a float or integer.
        if ( property.type != "MinMaxRange" )
            Debug.LogWarning( "Use only with MinMaxRange type" );
        else
        {
            var range = attribute as MinMaxRangeAttribute;
            var minValue = property.FindPropertyRelative( "rangeStart" );
            var maxValue = property.FindPropertyRelative( "rangeEnd" );
            var newMin = minValue.floatValue;
            var newMax = maxValue.floatValue;

            var xDivision = position.width * 0.33f;
            var yDivision = position.height * 0.5f;
            EditorGUI.LabelField( new Rect( position.x, position.y, xDivision, yDivision ), label );

            EditorGUI.LabelField( new Rect( position.x, position.y + yDivision, position.width, yDivision ), range.minLimit.ToString( "0.##" ) );
            EditorGUI.LabelField( new Rect( position.x + position.width - 28f, position.y + yDivision, position.width, yDivision ), range.maxLimit.ToString( "0.##" ) );
            EditorGUI.MinMaxSlider( new Rect( position.x + 24f, position.y + yDivision, position.width - 48f, yDivision ), ref newMin, ref newMax, range.minLimit, range.maxLimit );

            EditorGUI.LabelField( new Rect( position.x + xDivision, position.y, xDivision, yDivision ), "From: " );
            newMin = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision + 30, position.y, xDivision - 30, yDivision ), newMin ), range.minLimit, newMax );
            EditorGUI.LabelField( new Rect( position.x + xDivision * 2f, position.y, xDivision, yDivision ), "To: " );
            newMax = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision * 2f + 24, position.y, xDivision - 24, yDivision ), newMax ), newMin, range.maxLimit );

            minValue.floatValue = newMin;
            maxValue.floatValue = newMax;
        }
    }
开发者ID:tory37,项目名称:TorysUnityToolbox,代码行数:31,代码来源:MinMaxRangeDrawer.cs

示例2: OnGUI

    void OnGUI()
    {
        if (showStartingScreen) {
            int height = (int)(Screen.height * .2f);
            GUI.Box(new Rect(0, Screen.height / 2 - height / 2, Screen.width, height),"");

            GUIContent text = new GUIContent("" + ((num == 0) ? "GO" : num + ""));

            GUIStyle watStyle = new GUIStyle(textStyle);
            int x = 0;
            if (currTime < .2f) {
                x = (int)(currTime / .2f * Screen.width / 2 - watStyle.CalcSize(text).x / 2);
            } else if (currTime >= .2f && currTime <= .8f) {
                watStyle.fontSize += (int)(20 - 20*((Mathf.Abs(.5f - currTime))/.3f));
                x = (int)(Screen.width / 2 - watStyle.CalcSize(text).x / 2);
            } else if (currTime > .8f) {
                x = (int)((currTime - .8f) / .2f * Screen.width/2 - watStyle.CalcSize(text).x / 2 + Screen.width /2);
            }
            GUI.Label(new Rect(x, Screen.height / 2 - watStyle.CalcSize(text).y / 2, 100, 100),text, watStyle);

            currTime += Time.realtimeSinceStartup - lastTime;
            lastTime = Time.realtimeSinceStartup;
            if (currTime >= 1f) {
                currTime = 0f;
                num--;
            }

            if (num < 0) {
                showStartingScreen = false;
                Time.timeScale = 1;
            }
        }
    }
开发者ID:pmlamotte,项目名称:2Pac,代码行数:33,代码来源:GameStart.cs

示例3: Initialize

    void Initialize(SerializedProperty property)
    {
        if (listedScenes != null && listedScenes.Length > 0)
            return;

        var scenes = EditorBuildSettings.scenes;
        var selectableScenes = new System.Collections.Generic.List<EditorBuildSettingsScene>();

        SceneSelectionAttribute attr = (SceneSelectionAttribute)attribute;

        for (int i = 0; i < scenes.Length; i++)
        {
            if (scenes[i].enabled || attr.allowDisabledScenes)
                selectableScenes.Add(scenes[i]);
        }
        listedScenes = new GUIContent[selectableScenes.Count];

        for (int i = 0; i < listedScenes.Length; i++)
        {
            var path = selectableScenes[i].path;
            int lastSeparator = path.LastIndexOf("/") + 1;
            var sceneName = path.Substring(lastSeparator, path.LastIndexOf(".") - lastSeparator);
            listedScenes[i] = new GUIContent(sceneName, selectableScenes[i].enabled ? "Enabled" : "Disabled");
            if (listedScenes[i].text.Equals(property.stringValue))
                selectedIndex = i;
        }
    }
开发者ID:LuciusSixPercent,项目名称:Finsternis,代码行数:27,代码来源:ScenesPopupDrawer.cs

示例4: OnGUI

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
        WritableAttribute attr = attribute as WritableAttribute;
        GUI.enabled = attr.Result(DrawerUtil.GetTarget(property));
        DrawerUtil.OnGUI(position, property, label);
        GUI.enabled = true;

    }
开发者ID:toros11,项目名称:AbilitySystem,代码行数:7,代码来源:WritableAttributeDrawer.cs

示例5: OnGUI

    /// <summary>
    /// Show the RequiredField inspector. Changes depending on the field being
    /// empty or not.
    /// </summary>
    public override void OnGUI(Rect a_position, SerializedProperty a_property, GUIContent a_label)
    {
        // Split the widget position rectangle horizontally.
        Rect bottom = new Rect();
        Rect top = new Rect();
        SplitRect(a_position, ref top, ref bottom);

        // Save the default GUI color for later.
        Color defaultColor = GUI.color;

        // If the object pointed by the property is null, then show the error
        // message, and set the GUI color to red to display the PropertyField in
        // red.
        if(a_property.objectReferenceValue == null) {
            EditorGUI.HelpBox(top, "The field below is required and can't be empty.", MessageType.Error);
            GUI.color = Color.red;
        }

        // Draw the default property field, this drawer does not alter the GUI.
        if(a_property.objectReferenceValue == null) {
            EditorGUI.PropertyField(bottom, a_property, a_label);
        }
        else {
            EditorGUI.PropertyField(a_position, a_property, a_label);
        }

        // Restore the original colors.
        GUI.color = defaultColor;
    }
开发者ID:Judepompom,项目名称:Unity-RequiredField,代码行数:33,代码来源:RequiredFieldPropertyDrawer.cs

示例6: DrawLights

    void DrawLights(Light[] lights, ref int i)
    {
        GUIContent tooltip = new GUIContent("", "Is the game object active in hierarchy and the light component enabled.");
        foreach (Light light in lights)
        {
            if (light == null)
                continue;

            EditorGUI.BeginDisabledGroup(light.shadows == LightShadows.None);

            EditorGUILayout.BeginHorizontal();

            string controlName = "ObjectField-" + i;
            GUI.SetNextControlName(controlName);
            EditorGUILayout.ObjectField(light, typeof(Light), true);

            if (GUILayout.Button("Select"))
            {
                Selection.activeGameObject = light.gameObject;
                SceneView.lastActiveSceneView.FrameSelected();
                GUI.FocusControl(controlName);
            }
            if (GUILayout.Button("Disable shadows"))
            {
                light.shadows = LightShadows.None;
            }
            GUILayout.Toggle(light.gameObject.activeInHierarchy && light.enabled, tooltip, GUILayout.ExpandWidth (false));
            EditorGUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();
        }
    }
开发者ID:markkleeb,项目名称:ArcadeCabs2016,代码行数:32,代码来源:FindLightsWithShadows.cs

示例7: OnGUI

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        //EditorGUI.BeginProperty(position, GUIContent.none, property);
        //SerializedProperty memberProperty = property.FindPropertyRelative("PropertyName");
        //SerializedProperty typeProperty = property.FindPropertyRelative("Type");
        SerializedProperty propertyProperty = property.FindPropertyRelative("PropertyType");
        PropertyTypeInfo propertyTypeInfo = (PropertyTypeInfo) propertyProperty.enumValueIndex;
        SerializedProperty curve1Property = property.FindPropertyRelative("Curve1");
        SerializedProperty curve2Property = property.FindPropertyRelative("Curve2");
        SerializedProperty curve3Property = property.FindPropertyRelative("Curve3");
        SerializedProperty curve4Property = property.FindPropertyRelative("Curve4");

        int count = UnityPropertyTypeInfo.GetCurveCount(propertyTypeInfo);

        EditorGUI.indentLevel++;
            if(count > 0)
            EditorGUILayout.PropertyField(curve1Property);
            if (count > 1)
            EditorGUILayout.PropertyField(curve2Property);
            if (count > 2)
            EditorGUILayout.PropertyField(curve3Property);
            if (count > 3)
            EditorGUILayout.PropertyField(curve4Property);
        EditorGUI.indentLevel--;

        //EditorGUI.EndProperty();
    }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:27,代码来源:MemberClipCurveInspector.cs

示例8: IntField

    /** Draws an integer field */
    public int IntField(GUIContent label, int value, int offset, int adjust, out Rect r, out bool selected)
    {
        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;
        selected = on;

        if (Event.current.type == EventType.Repaint) {
            intStyle.Draw (r1,label,false,false,false,on);
        }

        return value;
    }
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:34,代码来源:GridGeneratorEditor.cs

示例9: Button

 /// <summary>
 /// Initializes a new instance of the <see cref="Button"/> class.
 /// </summary>
 /// <param name='bounds'>
 /// Bounds.
 /// </param>
 /// <param name='content'>
 /// Content.
 /// </param>
 /// <param name='style'>
 /// Style.
 /// </param>
 public Button(Rectangle bounds, GUIContent content, GUISkin skin)
     : this()
 {
     this.Bounds = bounds;
     this.Content = content;
     this.Skin = skin;
 }
开发者ID:miguelmartin75,项目名称:Survival,代码行数:19,代码来源:Button.cs

示例10: GetHcEffectControls_Rotate

 public static GUIContent[] GetHcEffectControls_Rotate()
 {
     GUIContent[]	cons = new GUIContent[2];
     cons[0]	= new GUIContent("Rot"	, "");
     cons[1]	= new GUIContent("Fix"	, "");
     return cons;
 }
开发者ID:seonwifi,项目名称:bongbong,代码行数:7,代码来源:FxmTestControls.cs

示例11: GetContent

 public GUIContent GetContent()
 {
     GUIContent gc = new GUIContent("");
     if(this.IsWeapon()) gc = DataHolder.Weapons().GetContent(this.equipID);
     else if(this.IsArmor()) gc = DataHolder.Armors().GetContent(this.equipID);
     return gc;
 }
开发者ID:hughrogers,项目名称:RPGQuest,代码行数:7,代码来源:EquipShort.cs

示例12: List

    // This function is ran inside of OnGUI()
    // For usage, see http://wiki.unity3d.com/index.php/PopupList#Javascript_-_PopupListUsageExample.js
    public int List(Rect box, GUIContent[] items, GUIStyle boxStyle, GUIStyle listStyle)
    {
        // If the instance's popup selection is visible
        if(isVisible) {

            // Draw a Box
            Rect listRect = new Rect( box.x, box.y + box.height, box.width, box.height * items.Length);
            GUI.Box( listRect, "", boxStyle );

            // Draw a SelectionGrid and listen for user selection
            selectedItemIndex = GUI.SelectionGrid( listRect, selectedItemIndex, items, 1, listStyle );

            // If the user makes a selection, make the popup list disappear
            if(GUI.changed) {
                current = null;
            }
        }

        // Get the control ID
        int controlID = GUIUtility.GetControlID( FocusType.Passive );

        // Listen for controls
        switch( Event.current.GetTypeForControl(controlID) )
        {
            // If mouse button is clicked, set all Popup selections to be retracted
            case EventType.mouseUp:
            {
                current = null;
                break;
            }
        }

        // Draw a button. If the button is clicked
        if(GUI.Button(new Rect(box.x,box.y,box.width,box.height),items[selectedItemIndex])) {

            // If the button was not clicked before, set the current instance to be the active instance
            if(!isClicked) {
                current = this;
                isClicked = true;
            }
            // If the button was clicked before (it was the active instance), reset the isClicked boolean
            else {
                isClicked = false;
            }
        }

        // If the instance is the active instance, set its popup selections to be visible
        if(current == this) {
            isVisible = true;
        }

        // These resets are here to do some cleanup work for OnGUI() updates
        else {
            isVisible = false;
            isClicked = false;
        }

        // Return the selected item's index
        return selectedItemIndex;
    }
开发者ID:WumboGames,项目名称:UnityBackup,代码行数:62,代码来源:Popup.cs

示例13: OnGUI

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty (position, label, property);

        // Draw label
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        // Get properties
        var clipProp = property.FindPropertyRelative("clip");
        var volumeProp = property.FindPropertyRelative("volume");
        var vLabelContent = new GUIContent("Volume");

        // Calc rects
        var clipRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

        var volumeRect = new Rect(position.x, position.y + clipRect.height, position.width, EditorGUIUtility.singleLineHeight);
        var vLabelRect = new Rect(volumeRect.x, volumeRect.y, 50, volumeRect.height);
        var vSliderRect = new Rect(volumeRect.x + vLabelRect.width, volumeRect.y, volumeRect.width - vLabelRect.width, volumeRect.height);

        // Create labels
        var clipLabel = new GUIContent("clip");
        var volumeLabel = new GUIContent("volume");

        // Draw fields
        EditorGUI.BeginProperty(clipRect, clipLabel, clipProp);
            EditorGUI.PropertyField(clipRect, clipProp, GUIContent.none);
        EditorGUI.EndProperty();
        EditorGUI.BeginProperty(volumeRect, volumeLabel, volumeProp);
            EditorGUI.LabelField(vLabelRect, vLabelContent);
            EditorGUI.PropertyField(vSliderRect, volumeProp, GUIContent.none);
        EditorGUI.EndProperty();

        EditorGUI.EndProperty();
    }
开发者ID:jilleJr,项目名称:Akira-Moto,代码行数:34,代码来源:_SoundEffectsHelper_Sound.cs

示例14: OnGUI

    /// <summary>
    /// 覆盖OnGUI方式,将使得BoolVector3的默认Inspector显示方式失效,采用自定义的显示方式
    /// </summary>
    /// <param name="position"></param>
    /// <param name="property"></param>
    /// <param name="label"></param>
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // 默认显示方式
        // base.OnGUI(position, property, label);

        // 自定义
        {
            // 1.获得自定义属性类中,我们需要绘制的属性
            SerializedProperty x = property.FindPropertyRelative("x");
            SerializedProperty y = property.FindPropertyRelative("y");
            SerializedProperty z = property.FindPropertyRelative("z");

            float propWidth = position.width / 6.0f;

            // 2.创建对应属性的文本描述
            EditorGUI.LabelField(new Rect(position.x, position.y, propWidth, position.height), "X");
            // 3.创建对应属性的实际控制组件(如 bool,我们使用Toggle)
            x.boolValue = EditorGUI.Toggle(new Rect(position.x + propWidth * 1, position.y, propWidth, position.height), x.boolValue);

            EditorGUI.LabelField(new Rect(position.x + propWidth * 2, position.y, propWidth, position.height), "Y");
            y.boolValue = EditorGUI.Toggle(new Rect(position.x + propWidth * 3, position.y, propWidth, position.height), y.boolValue);

            EditorGUI.LabelField(new Rect(position.x + propWidth * 4, position.y, propWidth, position.height), "Z");
            z.boolValue = EditorGUI.Toggle(new Rect(position.x + propWidth * 5, position.y, propWidth, position.height), z.boolValue);
        }
    }
开发者ID:289997171,项目名称:UnityCustomEditorSeriesExamples,代码行数:32,代码来源:BoolVector3Drawer.cs

示例15: unlocksMenu

    public void unlocksMenu(int id)
    {
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();

        UnlockData[] unlocks = FindObjectsOfType<UnlockData>();
        for (int i = 0; i < unlocks.Length; i++ ) {
            UnlockData unlock = unlocks[i];
            GUIContent content = new GUIContent();
            content.text = unlock.name;
            content.image = unlock.texture;
            content.tooltip = unlock.description;

            if (i != 0 && i % 2 == 0) {
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
            }

            GUI.enabled = unlock.isUnlocked;
            unlock.isActivated = GUILayout.Toggle(unlock.isActivated, content);
            GUI.enabled = true;
        }

        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        printButton("Back", () => currentMenu = 0);
    }
开发者ID:knexer,项目名称:BulletsEnemiesPortals,代码行数:27,代码来源:MainMenu.cs


注:本文中的GUIContent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。