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


C# Rect.ContainsMouse方法代码示例

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


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

示例1: OnGUI

        public void OnGUI()
        {
            if (Event.current.type == EventType.Repaint && MapView.MapIsEnabled)
            {
                foreach (ISatellite s in RTCore.Instance.Satellites.FindCommandStations().Concat(RTCore.Instance.Network.GroundStations.Values))
                {
                    bool showOnMapview = true;
                    var worldPos = ScaledSpace.LocalToScaledSpace(s.Position);
                    if (MapView.MapCamera.transform.InverseTransformPoint(worldPos).z < 0f) continue;
                    Vector3 pos = PlanetariumCamera.Camera.WorldToScreenPoint(worldPos);
                    var screenRect = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16);

                    // Hide the current ISatellite if it is behind its body
                    if (RTSettings.Instance.HideGroundStationsBehindBody && IsOccluded(s.Position, s.Body))
                        showOnMapview = false;

                    if (RTSettings.Instance.HideGroundStationsOnDistance && !IsOccluded(s.Position, s.Body) && this.IsCamDistanceToWide(s.Position))
                        showOnMapview = false;

                    // orbiting remote stations are always shown
                    if(s.isVessel && !s.parentVessel.Landed)
                        showOnMapview = true;

                    if (showOnMapview)
                    {
                        Color pushColor = GUI.color;
                        // tint the white mark.png into the defined color
                        GUI.color = s.MarkColor;
                        // draw the mark.png
                        GUI.DrawTexture(screenRect, mTexMark, ScaleMode.ScaleToFit, true);
                        GUI.color = pushColor;

                        // Show Mouse over informations to the ground station
                        if (RTSettings.Instance.ShowMouseOverInfoGroundStations && s is MissionControlSatellite && screenRect.ContainsMouse())
                        {
                            Rect headline = screenRect;
                            Vector2 nameDim = this.smallStationHead.CalcSize(new GUIContent(s.Name));

                            headline.x -= nameDim.x + 10;
                            headline.y -= 3;
                            headline.width = nameDim.x;
                            headline.height = 14;
                            // draw headline of the station
                            GUI.Label(headline, s.Name, this.smallStationHead);

                            // loop antennas
                            String antennaRanges = String.Empty;
                            foreach (var antenna in s.Antennas)
                            {
                                if(antenna.Omni > 0)
                                {
                                    antennaRanges += "Omni: "+ RTUtil.FormatSI(antenna.Omni,"m") + Environment.NewLine;
                                }
                                if (antenna.Dish > 0)
                                {
                                    antennaRanges += "Dish: " + RTUtil.FormatSI(antenna.Dish, "m") + Environment.NewLine;
                                }
                            }

                            if(!antennaRanges.Equals(String.Empty))
                            {
                                Rect antennas = screenRect;
                                GUIContent content = new GUIContent(antennaRanges);

                                Vector2 antennaDim = this.smallStationText.CalcSize(content);
                                float maxHeight = this.smallStationText.CalcHeight(content, antennaDim.x);

                                antennas.y += headline.height - 3;
                                antennas.x -= antennaDim.x + 10;
                                antennas.width = antennaDim.x;
                                antennas.height = maxHeight;

                                // draw antenna infos of the station
                                GUI.Label(antennas, antennaRanges, this.smallStationText);
                            }
                        }
                    }
                }
            }
        }
开发者ID:RemoteTechnologiesGroup,项目名称:RemoteTech,代码行数:80,代码来源:NetworkRenderer.cs


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