本文整理汇总了C#中UnityEngine.Rect类的典型用法代码示例。如果您正苦于以下问题:C# Rect类的具体用法?C# Rect怎么用?C# Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rect类属于UnityEngine命名空间,在下文中一共展示了Rect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttachView
public bool AttachView(EditorWindow parent, ScriptableObject webView, bool initialize = false)
{
this.parentWin = parent;
this.internalWebView = webView;
if (this.internalWebView != null)
{
this.hostView = Tools.GetReflectionField<object>(parent, "m_Parent");
this.dockedGetterMethod = this.parentWin.GetType().GetProperty("docked", Tools.FullBinding).GetGetMethod(true);
if (this.hostView != null && dockedGetterMethod != null)
{
if (initialize)
{
Rect initViewRect = new Rect(0, 20, this.parentWin.position.width, this.parentWin.position.height - ((this.IsDocked()) ? 20 : 40));
this.InitWebView(this.hostView, (int)initViewRect.x, (int)initViewRect.y, (int)initViewRect.width, (int)initViewRect.height, false);
this.SetHideFlags(HideFlags.HideAndDontSave);
this.AllowRightClickMenu(true);
}
}
else
{
throw new Exception("Failed to get parent window or docked property");
}
}
return (this.internalWebView != null);
}
示例2: 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();
}
示例3: HierarchyItemCB
static void HierarchyItemCB(int instanceID, Rect selectionRect)
{
GameObject go = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
if (go == null)
{
return;
}
if (_icon != null && go.GetComponent<ProCamera2D>() != null)
{
Rect r = new Rect(selectionRect);
r.x = r.width - 5;
GUI.Label(r, _icon);
return;
}
if (_icon_plugin != null && go.GetComponent<BasePC2D>() != null)
{
Rect r = new Rect(selectionRect);
r.x = r.width - 5;
GUI.Label(r, _icon_plugin);
}
}
示例4: CalculateOffset
void CalculateOffset()
{
// Remove the delta movement
_transform.Translate(-ProCamera2D.DeltaMovement, Space.World);
// Calculate the window rect
_cameraWindowRectInWorldCoords = GetRectAroundTransf(CameraWindowRect, ProCamera2D.ScreenSizeInWorldCoordinates, _transform);
// If camera final horizontal position outside camera window rect
var horizontalDeltaMovement = 0f;
if (ProCamera2D.CameraTargetPositionSmoothed.x >= _cameraWindowRectInWorldCoords.x + _cameraWindowRectInWorldCoords.width)
{
horizontalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.x - (Vector3H(_transform.localPosition) + _cameraWindowRectInWorldCoords.width / 2 + CameraWindowRect.x);
}
else if (ProCamera2D.CameraTargetPositionSmoothed.x <= _cameraWindowRectInWorldCoords.x)
{
horizontalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.x - (Vector3H(_transform.localPosition) - _cameraWindowRectInWorldCoords.width / 2 + CameraWindowRect.x);
}
// If camera final vertical position outside camera window rect
var verticalDeltaMovement = 0f;
if (ProCamera2D.CameraTargetPositionSmoothed.y >= _cameraWindowRectInWorldCoords.y + _cameraWindowRectInWorldCoords.height)
{
verticalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.y - (Vector3V(_transform.localPosition) + _cameraWindowRectInWorldCoords.height / 2 + CameraWindowRect.y);
}
else if (ProCamera2D.CameraTargetPositionSmoothed.y <= _cameraWindowRectInWorldCoords.y)
{
verticalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.y - (Vector3V(_transform.localPosition) - _cameraWindowRectInWorldCoords.height / 2 + CameraWindowRect.y);
}
var deltaMovement = VectorHV(horizontalDeltaMovement, verticalDeltaMovement);
_transform.Translate(deltaMovement, Space.World);
}
示例5: Awake
private void Awake()
{
instance = this;
GameEvents.onShowUI.Add(OnShowUI);
GameEvents.onHideUI.Add(OnHideUI);
mainGuid = Guid.NewGuid().GetHashCode();
bodyGuid = Guid.NewGuid().GetHashCode();
configGuid = Guid.NewGuid().GetHashCode();
MainWindowRect = new Rect(Screen.width / 4, 0, 200, 10); //Overwritten by LoadGUI
BodyWindowRect = new Rect((Screen.width / 2) - 75, Screen.height / 4, 150, 10);
ConfigWindowRect = new Rect((Screen.width / 2) - 100, Screen.height / 4, 200, 10);
LoadGUI();
if (visibility_mode == 2)
{
CreateStockToolbar();
}
else if (visibility_mode == 3)
{
CreateBlizzyToolbar();
}
}
示例6: OnWindowGUI
public virtual void OnWindowGUI(Rect viewRect)
{
if(!isShown && CanShow())
{
isShown = true;
DoShow();
}
if(isShown && !CanShow())
{
isShown = false;
DoHide();
}
if(CanShow())
{
windowRect = GUILayout.Window(windowID, windowRect, DoWindow, header);
DoGUI();
if(isHovered)
{
int controlID = GUIUtility.GetControlID("WindowHovered".GetHashCode(), FocusType.Passive);
if(Event.current.GetTypeForControl(controlID) == EventType.Layout)
{
HandleUtility.AddControl(controlID,0f);
}
}
}
}
示例7: DoStockpileSelectors
// RimWorld.AreaAllowedGUI
public static void DoStockpileSelectors( Rect rect, ref Zone_Stockpile stockpile, Map map )
{
// get all stockpiles
List<Zone_Stockpile> allStockpiles = map.zoneManager.AllZones.OfType<Zone_Stockpile>().ToList();
// count + 1 for all stockpiles
int areaCount = allStockpiles.Count + 1;
// create colour swatch
if ( textures == null || textures.Count != areaCount - 1 )
CreateTextures( allStockpiles );
float widthPerCell = rect.width / areaCount;
Text.WordWrap = false;
Text.Font = GameFont.Tiny;
Rect nullAreaRect = new Rect( rect.x, rect.y, widthPerCell, rect.height );
DoZoneSelector( nullAreaRect, ref stockpile, null, BaseContent.GreyTex );
int areaIndex = 1;
for( int j = 0; j < allStockpiles.Count; j++ )
{
float xOffset = areaIndex * widthPerCell;
Rect stockpileRect = new Rect( rect.x + xOffset, rect.y, widthPerCell, rect.height );
DoZoneSelector( stockpileRect, ref stockpile, allStockpiles[j], textures[j] );
areaIndex++;
}
Text.WordWrap = true;
Text.Font = GameFont.Small;
}
示例8: CreateDecal
public static GameObject CreateDecal(Material mat, Rect uvCoords, float scale)
{
GameObject decal = new GameObject();
decal.name = "Decal" + decal.GetInstanceID();
decal.AddComponent<MeshFilter>().sharedMesh = DecalMesh("DecalMesh" + decal.GetInstanceID(), mat, uvCoords, scale);
decal.AddComponent<MeshRenderer>().sharedMaterial = mat;
#if UNITY_5
decal.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
#else
decal.GetComponent<MeshRenderer>().castShadows = false;
#endif
qd_Decal decalComponent = decal.AddComponent<qd_Decal>();
decalComponent.SetScale(scale);
decalComponent.SetTexture( (Texture2D)mat.mainTexture );
decalComponent.SetUVRect(uvCoords);
#if DEBUG
decal.AddComponent<qd_DecalDebug>();
#endif
return decal;
}
示例9: DoListView
private static ListViewShared.ListViewElementsEnumerator DoListView(ListViewState state, int[] colWidths, string dragTitle)
{
Rect rect = ListViewGUILayout.dummyRect;
int yFrom = 0;
int yTo = 0;
ListViewShared.InternalLayoutedListViewState ilvState = state.ilvState;
int controlId = GUIUtility.GetControlID(ListViewGUILayout.listViewHash, FocusType.Native);
state.ID = controlId;
state.selectionChanged = false;
ilvState.state = state;
if (Event.current.type != EventType.Layout)
{
rect = new Rect(0.0f, state.scrollPos.y, GUIClip.visibleRect.width, GUIClip.visibleRect.height);
if ((double) rect.width <= 0.0)
rect.width = 1f;
if ((double) rect.height <= 0.0)
rect.height = 1f;
state.ilvState.rect = rect;
yFrom = (int) rect.yMin / state.rowHeight;
yTo = yFrom + (int) Math.Ceiling(((double) rect.yMin % (double) state.rowHeight + (double) rect.height) / (double) state.rowHeight) - 1;
ilvState.invisibleRows = yFrom;
ilvState.endRow = yTo;
ilvState.rectHeight = (int) rect.height;
if (yFrom < 0)
yFrom = 0;
if (yTo >= state.totalRows)
yTo = state.totalRows - 1;
}
if (colWidths == null)
{
ListViewGUILayout.dummyWidths[0] = (int) rect.width;
colWidths = ListViewGUILayout.dummyWidths;
}
return new ListViewShared.ListViewElementsEnumerator((ListViewShared.InternalListViewState) ilvState, colWidths, yFrom, yTo, dragTitle, new Rect(0.0f, (float) (yFrom * state.rowHeight), rect.width, (float) state.rowHeight));
}
示例10: Line
public static void Line(float yOrigin, Color color)
{
var rect = new Rect(0, yOrigin, Screen.width, 1);
GUI.color = color;
GUI.DrawTexture(rect, Drawing.Pixel);
Colors.ResetUIColor();
}
示例11: Display
internal static void Display(int windowId)
{
// Reset Tooltip active flag...
ToolTipActive = false;
Rect rect = new Rect(Position.width - 20, 4, 16, 16);
if (GUI.Button(rect, new GUIContent("", "Close Window")))
{
ShowWindow = false;
ToolTip = "";
}
if (Event.current.type == EventType.Repaint && ShowToolTips)
ToolTip = SMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
// This is a scroll panel (we are using it to make button lists...)
GUILayout.BeginVertical();
DisplayWindowTabs();
// This is a scroll panel (we are using it to make button lists...)
_displayViewerPosition = GUILayout.BeginScrollView(_displayViewerPosition, SMStyle.ScrollStyle,
GUILayout.Height(200), GUILayout.Width(370));
DisplaySelectedTab(_displayViewerPosition);
GUILayout.EndScrollView();
DisplayTabActions();
GUILayout.EndVertical();
GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
SMAddon.RepositionWindow(ref Position);
}
示例12: DrawPanel
private static void DrawPanel(Rect rect, Color color, PanelStyleOption option)
{
GUI.color = color;
GUI.Box(rect, "", PanelStyle(option));
Colors.ResetUIColor();
}
示例13: DrawFilledCurve
public static void DrawFilledCurve(Rect r, AudioCurveRendering.AudioCurveAndColorEvaluator eval)
{
if (Event.current.type != EventType.Repaint)
return;
HandleUtility.ApplyWireMaterial();
GL.Begin(1);
float pixelsPerPoint = EditorGUIUtility.pixelsPerPoint;
float num1 = 1f / pixelsPerPoint;
float num2 = 0.5f * num1;
float num3 = Mathf.Ceil(r.width) * pixelsPerPoint;
float num4 = Mathf.Floor(r.x) + AudioCurveRendering.pixelEpsilon;
float num5 = 1f / (num3 - 1f);
float max = r.height * 0.5f;
float num6 = r.y + 0.5f * r.height;
float y = r.y + r.height;
Color col;
float b = Mathf.Clamp(max * eval(0.0f, out col), -max, max);
for (int index = 0; (double) index < (double) num3; ++index)
{
float x = num4 + (float) index * num1;
float a = Mathf.Clamp(max * eval((float) index * num5, out col), -max, max);
float num7 = Mathf.Min(a, b) - num2;
float num8 = Mathf.Max(a, b) + num2;
GL.Color(new Color(col.r, col.g, col.b, 0.0f));
AudioMixerDrawUtils.Vertex(x, num6 - num8);
GL.Color(col);
AudioMixerDrawUtils.Vertex(x, num6 - num7);
AudioMixerDrawUtils.Vertex(x, num6 - num7);
AudioMixerDrawUtils.Vertex(x, y);
b = a;
}
GL.End();
}
示例14: BeginCurveFrame
public static Rect BeginCurveFrame(Rect r)
{
AudioCurveRendering.DrawCurveBackground(r);
r = AudioCurveRendering.DrawCurveFrame(r);
GUI.BeginGroup(r);
return new Rect(0.0f, 0.0f, r.width, r.height);
}
示例15: OnGUI
override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
if (!checkVisible (editor)) return;
Color col = GUI.contentColor;
Color bcol = GUI.backgroundColor;
GUI.contentColor = new Color(1f, 1f, 0.8f, 1f);
GUI.backgroundColor = backgroundColor;
//position.y -= 15;
Rect pos=new Rect(position);
pos.y += 3;
pos.height -= 3;
//if (visibilityProp1==null || visibilityProp1=="indent") {
// pos.height -= 10;
// pos.y += 10;
//}
if (visibilityProp1!=null) {
pos.x+=12;
pos.width-=12;
}
// pos.height = 17;
EditorGUI.HelpBox(pos, (foldoutFlag ? " ":"")+label, MessageType.None);
if (foldoutFlag) {
Rect fpos = new Rect(pos);
fpos.x += 15;
fpos.y += 1;
bool state = EditorGUI.Foldout(fpos, prop.floatValue==1, "", true);
prop.floatValue = state ? 1 : 0;
}
GUI.contentColor = col;
GUI.backgroundColor = bcol;
}