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


C# Rect.GetHashCode方法代码示例

本文整理汇总了C#中UnityEngine.Rect.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.GetHashCode方法的具体用法?C# Rect.GetHashCode怎么用?C# Rect.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Rect的用法示例。


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

示例1: goodButton

	// GUI system workaround about a GUI control layered on top of a button
	// see e.g. http://forum.unity3d.com/threads/96563-corrected-GUI.Button-code-%28works-properly-with-layered-controls%29
	public static bool goodButton (Rect bounds, string caption)
	{
		GUIStyle btnStyle = GUI.skin.FindStyle ("button");
		int controlID = GUIUtility.GetControlID (bounds.GetHashCode (), FocusType.Passive);
		
		bool isMouseOver = bounds.Contains (UnityEngine.Event.current.mousePosition);
		bool isDown = GUIUtility.hotControl == controlID;
		
		if (GUIUtility.hotControl != 0 && !isDown) {
			// ignore mouse while some other control has it
			// (this is the key bit that GUI.Button appears to be missing)
			isMouseOver = false;
		}
		
		if (UnityEngine.Event.current.type == EventType.Repaint)
		{
			btnStyle.Draw (bounds, new GUIContent (caption), isMouseOver, isDown, false, false);
		}
		
		switch (UnityEngine.Event.current.GetTypeForControl (controlID))
		{
		
		case EventType.mouseDown:
			if (isMouseOver) {
				// (note: isMouseOver will be false when another control is hot)
				GUIUtility.hotControl = controlID;
			}
			
			// GUIUtility.hotControl = controlID; // button is broken: we get slider AND button ( which is what we want )
			
			break;
		
		case EventType.mouseUp:
			if (GUIUtility.hotControl == controlID)
				GUIUtility.hotControl = 0;
			if (bounds.Contains (UnityEngine.Event.current.mousePosition))
				return true;
			break;
		}
		
		return false;
	}
开发者ID:r618,项目名称:endgame-singularity-ii,代码行数:44,代码来源:GUIHelpers.cs

示例2: Draw

        public void Draw(Rect rect, ThingWithComps ownerPawn)
        {
            Text.Font = GameFont.Small;
            string value = "-";

            switch (oType)
            {
                case objectType.Stat:
                    Text.Anchor = TextAnchor.MiddleCenter;
                    StatDef stat = (StatDef)displayObject;
                    string statValue = (stat.ValueToString(ownerPawn.GetStatValue((StatDef)displayObject, true)));
                    Widgets.Label(rect, statValue);
                    if (Mouse.IsOver(rect))
                    {
                        GUI.DrawTexture(rect, TexUI.HighlightTex);
                    }

                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine(stat.LabelCap);
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine(stat.description);                
                    TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), rect.GetHashCode()));
                    break;    

                case objectType.Skill:
                    if ((ownerPawn is Pawn) && (ownerPawn as Pawn).RaceProps.Humanlike) DrawSkill(rect, ownerPawn as Pawn);
                    break;

                case objectType.Need:
                    if (ownerPawn is Pawn) DrawNeed(rect, ownerPawn as Pawn);
                    break;

                case objectType.Age:
                    Text.Anchor = TextAnchor.MiddleCenter;
                    string ageValue = ((ownerPawn as Pawn).ageTracker.AgeBiologicalYears.ToString());
                    Widgets.Label(rect, ageValue);
                    if (Mouse.IsOver(rect))
                    {
                        GUI.DrawTexture(rect, TexUI.HighlightTex);
                    }
                    break;

                case objectType.Gear:
                    DrawGear(rect, ownerPawn);
                    break;

                case objectType.ControlPrisonerGetsFood:
                    if (ownerPawn is Pawn)
                    {
                        if (Mouse.IsOver(rect))
                        {
                            GUI.DrawTexture(rect, TexUI.HighlightTex);
                        }
                        bool getsFood = (ownerPawn as Pawn).guest.GetsFood;
                        Widgets.CheckboxLabeled(new Rect(rect.x + 8f, rect.y + 3f, 27f, 27f), "", ref getsFood, false);
                        (ownerPawn as Pawn).guest.GetsFood = getsFood;
                    }
                    break;

                case objectType.ControlPrisonerInteraction:
                    if (ownerPawn is Pawn)
                    {
                        if (Mouse.IsOver(rect))
                        {
                            GUI.DrawTexture(rect, TexUI.HighlightTex);
                        }
                        float x = 8f;

                        GUI.BeginGroup(rect);
                        IEnumerator enumerator = Enum.GetValues(typeof(PrisonerInteractionMode)).GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                PrisonerInteractionMode prisonerInteractionMode = (PrisonerInteractionMode)((byte)enumerator.Current);
                                if (Widgets.RadioButton(new Vector2(x, 3f), (ownerPawn as Pawn).guest.interactionMode == prisonerInteractionMode))
                                {
                                    (ownerPawn as Pawn).guest.interactionMode = prisonerInteractionMode;
                                }
                                TooltipHandler.TipRegion(new Rect(x, 0f, 30f, 30f), new TipSignal(prisonerInteractionMode.GetLabel()));
                                x += 30f;
                            }
                        }
                        finally
                        {
                            IDisposable disposable = enumerator as IDisposable;
                            if (disposable != null)
                            {
                                disposable.Dispose();
                            }
                        }
                        GUI.EndGroup();
                    }
                    break;

                case objectType.ControlMedicalCare:
                    if (ownerPawn is Pawn) MedicalCareSetter(rect, ref (ownerPawn as Pawn).playerSettings.medCare);
                    break;

                case objectType.AnimalMilkFullness:
//.........这里部分代码省略.........
开发者ID:SteaNN,项目名称:Hardcore-SK,代码行数:101,代码来源:KListObject.cs

示例3: DrawNeed

        private void DrawNeed(Rect rect, Pawn ownerPawn)
        {
            if (ownerPawn.RaceProps.IsMechanoid) return;
            if (ownerPawn.needs == null) return;
            //TODO: rebuild using code in DrawOnGUI
            Need need = ownerPawn.needs.TryGetNeed((NeedDef)displayObject);
            if (need == null) return;

            if (Mouse.IsOver(rect))
            {
                Widgets.DrawHighlight(rect);
            }

            TooltipHandler.TipRegion(rect, new TipSignal(() => need.GetTipString(), rect.GetHashCode()));
            float num2 = 14f;
            float num3 = num2 + 15f;
            if (rect.height < 50f)
            {
                num2 *= Mathf.InverseLerp(0f, 50f, rect.height);
            }

            

            Text.Font = ((rect.height <= 55f) ? GameFont.Tiny : GameFont.Small);
            Text.Anchor = TextAnchor.UpperLeft;
            Rect rect3 = new Rect(rect.x, rect.y + rect.height / 2f, rect.width, rect.height / 2f);
            rect3 = new Rect(rect3.x + num3, rect3.y, rect3.width - num3 * 2f, rect3.height - num2);
            Widgets.FillableBar(rect3, need.CurLevelPercentage);
            Widgets.FillableBarChangeArrows(rect3, need.GUIChangeArrow);
            List<float> threshPercents = (List<float>)needThreshPercent.GetValue(need);
            if (threshPercents != null)
            {
                for (int i = 0; i < threshPercents.Count; i++)
                {
                    needDrawBarThreshold(rect3, threshPercents[i], need.CurLevelPercentage);
                }
            }
            float curInstantLevel = need.CurInstantLevelPercentage;
            if (curInstantLevel >= 0f)
            {
                needDrawBarInstantMarkerAt(rect3, curInstantLevel);
            }   
            Text.Font = GameFont.Small;
        }
开发者ID:SteaNN,项目名称:Hardcore-SK,代码行数:44,代码来源:KListObject.cs

示例4: Button

    public static bool Button(Rect bounds, string caption, GUIStyle btnStyle = null )
    {
        int controlID = GUIUtility.GetControlID(bounds.GetHashCode(), FocusType.Passive);
        bool isMouseOver = bounds.Contains(Event.current.mousePosition);
        int depth = (1000 - GUI.depth) * 1000 + controlID;
        if ( isMouseOver && depth > highestDepthID ) highestDepthID = depth;
        bool isTopmostMouseOver = (highestDepthID == depth);

        bool paintMouseOver = isTopmostMouseOver;

 
        if ( btnStyle == null )
        {
            btnStyle = new GUIStyle(HighLogic.Skin.button);
        }
           
        if ( Event.current.type == EventType.Layout && lastEventType != EventType.Layout )
        {
            highestDepthID = 0;
        }
        lastEventType = Event.current.type;
   
        if ( Event.current.type == EventType.Repaint )
        {
            bool isDown = (GUIUtility.hotControl == controlID);
            btnStyle.Draw(bounds, new GUIContent(caption), paintMouseOver, isDown, false, false);          
           
        }

       switch ( Event.current.GetTypeForControl(controlID) )
        {
            case EventType.mouseDown:
            {
                if ( isTopmostMouseOver)
                {
                    GUIUtility.hotControl = controlID;
                }
                break;
            }
 
            case EventType.mouseUp:
            {
                if ( isTopmostMouseOver)
                {
                    GUIUtility.hotControl = 0;
                    return true;
                }
                break;
            }
        }
        return false;
    }
开发者ID:nanathan,项目名称:Kolonization,代码行数:52,代码来源:MKSGui.cs

示例5: Draw

        public void Draw(Rect rect, Pawn ownerPawn)
        {
            switch (oType)
            {
                case objectType.Stat:
                    Text.Anchor = TextAnchor.MiddleCenter;
                    StatDef stat = (StatDef)displayObject;
                    string statValue = (stat.ValueToString(ownerPawn.GetStatValue((StatDef)displayObject, true)));
                    Widgets.Label(rect, statValue);
                    if (Mouse.IsOver(rect))
                    {
                        GUI.DrawTexture(rect, TexUI.HighlightTex);
                    }

                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine(stat.LabelCap);
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine(stat.description);                
                    TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), rect.GetHashCode()));
                    break;    

                case objectType.Skill:
                    DrawSkill(rect, ownerPawn);
                    break;

                case objectType.Need:
                    DrawNeed(rect, ownerPawn);
                    break;

                case objectType.Gear:
                    DrawGear(rect, ownerPawn);
                    break;

                case objectType.ControlPrisonerGetsFood:
                    if (Mouse.IsOver(rect))
                    {
                        GUI.DrawTexture(rect, TexUI.HighlightTex);
                    }
                    bool getsFood = ownerPawn.guest.GetsFood;
                    Widgets.LabelCheckbox(new Rect(rect.x + 8f, rect.y + 3f, 27f, 27f), "", ref getsFood, false);
                    ownerPawn.guest.GetsFood = getsFood;
                    break;

                case objectType.ControlPrisonerInteraction:
                    if (Mouse.IsOver(rect))
                    {
                        GUI.DrawTexture(rect, TexUI.HighlightTex);
                    }
                    float x = 8f;

                    GUI.BeginGroup(rect);
                    IEnumerator enumerator = Enum.GetValues(typeof(PrisonerInteractionMode)).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            PrisonerInteractionMode prisonerInteractionMode = (PrisonerInteractionMode)((byte)enumerator.Current);
                            if (Widgets.RadioButton(new Vector2(x, 3f), ownerPawn.guest.interactionMode == prisonerInteractionMode))
                            {
                                ownerPawn.guest.interactionMode = prisonerInteractionMode;
                            }
                            TooltipHandler.TipRegion(new Rect(x,0f,30f,30f), new TipSignal(prisonerInteractionMode.GetLabel()));
                            x += 30f;
                        }
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    GUI.EndGroup();
                    
                    break;

                case objectType.ControlMedicalCare:
                    MedicalCareSetter(rect, ref ownerPawn.playerSettings.medCare);
                    break;
            }


        }
开发者ID:scyde,项目名称:Hardcore-SK,代码行数:84,代码来源:KListObject.cs

示例6: DoWindowContents

        public override void DoWindowContents(Rect r)
        {
            maxWindowWidth = Screen.width;
            base.DoWindowContents(r);

            if (pawnListUpdateNext < Find.TickManager.TicksGame)
                isDirty = true;

            if (isDirty)
            {
                UpdatePawnList();
            }

            Rect position = new Rect(0f, 0f, r.width, 115f);
            GUI.BeginGroup(position);

            float x = 0f;
            Text.Font = GameFont.Small;

            //pawn/prisoner list switch
            Rect sourceButton = new Rect(x, 0f, buttonWidth, PawnRowHeight);
            if (Widgets.ButtonText(sourceButton, ("koisama.pawntype." + chosenPawnType.ToString()).Translate()))
            {
                PawnSelectOptionsMaker();
            }
            x += buttonWidth + 10;
            TooltipHandler.TipRegion(sourceButton, new TipSignal("koisama.Numbers.ClickToToggle".Translate(), sourceButton.GetHashCode()));

            //stats btn
            Rect addColumnButton = new Rect(x, 0f, buttonWidth, PawnRowHeight);
            if (Widgets.ButtonText(addColumnButton, "koisama.Numbers.AddColumnLabel".Translate()))
            {
                StatsOptionsMaker();
            }
            x += buttonWidth + 10;

            //skills btn
            if (new[] { pawnType.Colonists, pawnType.Prisoners, pawnType.Enemies }.Contains(chosenPawnType))
            {
                Rect skillColumnButton = new Rect(x, 0f, buttonWidth, PawnRowHeight);
                if (Widgets.ButtonText(skillColumnButton, "koisama.Numbers.AddSkillColumnLabel".Translate()))
                {
                    SkillsOptionsMaker();
                }
                x += buttonWidth + 10;
            }

            //needs btn
            Rect needsColumnButton = new Rect(x, 0f, buttonWidth, PawnRowHeight);
            if (Widgets.ButtonText(needsColumnButton, "koisama.Numbers.AddNeedsColumnLabel".Translate()))
            {
                NeedsOptionsMaker();
            }
            x += buttonWidth + 10;

            Rect otherColumnBtn = new Rect(x, 0f, buttonWidth, PawnRowHeight);
            if (Widgets.ButtonText(otherColumnBtn, "koisama.Numbers.AddOtherColumnLabel".Translate()))
            {
                OtherOptionsMaker();
            }
            x += buttonWidth + 10;

            //TODO: implement
            /*
            Rect addPresetBtn = new Rect(x, 0f, buttonWidth, PawnRowHeight);
            if (Widgets.ButtonText(addPresetBtn, "koisama.Numbers.SetPresetLabel".Translate()))
            {
                PresetOptionsMaker();
            }
            x += buttonWidth + 10;
            */

            Rect thingCount = new Rect(10f, 45f, 200f, 30f);
            Widgets.Label(thingCount, "koisama.Numbers.Count".Translate() + ": " + this.things.Count().ToString());

            x = 0;
            //names
            Rect nameLabel = new Rect(x, 75f, NameColumnWidth, PawnRowHeight);
            Text.Anchor = TextAnchor.LowerCenter;
            Widgets.Label(nameLabel, "koisama.Numbers.Name".Translate());
            if (Widgets.ButtonInvisible(nameLabel))
            {
                if (chosenOrderBy == orderBy.Name)
                {
                    pawnListDescending = !pawnListDescending;
                }
                else
                {
                    chosenOrderBy = orderBy.Name;
                    pawnListDescending = false;
                }
                isDirty = true;
            }

            TooltipHandler.TipRegion(nameLabel, "koisama.Numbers.SortByTooltip".Translate("koisama.Numbers.Name".Translate()));
            Widgets.DrawHighlightIfMouseover(nameLabel);
            x += NameColumnWidth;

            //header
            //TODO: better interface - auto width calculation
//.........这里部分代码省略.........
开发者ID:SteaNN,项目名称:Hardcore-SK,代码行数:101,代码来源:MainTabWindow_Numbers.cs


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