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


C# RectOffset.Remove方法代码示例

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


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

示例1: OnInspectorGUI

        public override void OnInspectorGUI()
        {
            EditorGUILayout.BeginVertical( EditorStyles.inspectorDefaultMargins );

            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField( serializedObject.FindProperty( "material" ) );

            if( EditorGUI.EndChangeCheck() )
            {
                CreateImportSprites();
            }

            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.EndVertical();

            TileSet tileSet = target as TileSet;

            if( tileSet.material != null )
            {
                if( tileSet.material.mainTexture != null )
                {
                    EditorGUILayout.BeginVertical( EditorStyles.inspectorDefaultMargins );

                    string texturePath = AssetDatabase.GetAssetPath( tileSet.material.mainTexture );

                    TextureImporter textureImporter = AssetImporter.GetAtPath( texturePath ) as TextureImporter;

                    if( textureImporter != null && textureImporter.filterMode != FilterMode.Point )
                    {
                        EditorGUILayout.BeginVertical( (GUIStyle)"HelpBox" );

                        GUILayout.Box( new GUIContent( "FilterMode is not Point.\nAre you sure you want to change to Point?",EditorTools.helpWarnIcon ),GUIStyle.none );

                        if( GUILayout.Button ( "Change to Point" ) )
                        {
                            textureImporter.filterMode = FilterMode.Point;

                            AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
                        }

                        EditorGUILayout.EndVertical();
                    }

                    _ImportFoldout = HeaderGUI(_ImportFoldout, "Import from sprites");
                    if (_ImportFoldout)
                    {
                        EditorGUILayout.BeginVertical(Styles.greyBorder);

                        bool importable = textureImporter != null && textureImporter.spriteImportMode != SpriteImportMode.None;

                        if (importable)
                        {
                            _ImportSize = EditorGUILayout.IntField("Import Size", _ImportSize);

                            _SpritesScrollPos = EditorGUILayout.BeginScrollView(_SpritesScrollPos,false,false,GUI.skin.horizontalScrollbar,GUI.skin.verticalScrollbar,"As TextArea",GUILayout.Height(300.0f));

                            // TODO:インポート対象の選択
                            for (int index = 0; index < textureImporter.spritesheet.Length;index++ )
                            {
                                SpriteMetaData sprite = textureImporter.spritesheet[index];

                                RectOffset margin = new RectOffset(4, 4, 4, 4);
                                EditorGUILayout.BeginHorizontal(Styles.greyBorder);
                                _ImportSprites[index] = EditorGUILayout.ToggleLeft("", _ImportSprites[index], GUILayout.Width(16));

                                float spriteWidth = sprite.rect.width + 8;
                                float spriteHeight = sprite.rect.height + 8;

                                Rect rect = GUILayoutUtility.GetRect(spriteWidth, spriteWidth, spriteHeight, spriteHeight, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
                                rect = margin.Remove(rect);

                                Rect texCoords = new Rect(sprite.rect.x / tileSet.material.mainTexture.width, sprite.rect.y / tileSet.material.mainTexture.height,
                                    sprite.rect.width / tileSet.material.mainTexture.width, sprite.rect.height / tileSet.material.mainTexture.height);
                                GUI.DrawTextureWithTexCoords(rect, tileSet.material.mainTexture, texCoords);

                                EditorGUILayout.LabelField(sprite.name);
                                EditorGUILayout.EndHorizontal();
                            }

                            EditorGUILayout.EndScrollView();

                            EditorGUILayout.BeginHorizontal();

                            if (GUILayout.Button("Check All", EditorStyles.miniButtonLeft, GUILayout.Width(100.0f)))
                            {
                                for (int index = 0; index < textureImporter.spritesheet.Length; index++)
                                {
                                    _ImportSprites[index] = true;
                                }
                            }

                            if (GUILayout.Button("Uncheck All", EditorStyles.miniButtonLeft, GUILayout.Width(100.0f)))
                            {
                                for (int index = 0; index < textureImporter.spritesheet.Length; index++)
                                {
                                    _ImportSprites[index] = false;
//.........这里部分代码省略.........
开发者ID:sgmtjp,项目名称:Git-SODATERUTOWER,代码行数:101,代码来源:TileSetInspector.cs

示例2: PropertyGUI

        void PropertyGUI( ILayerProperty property )
        {
            bool focused = focusedWindow == this;

            RectOffset margin = new RectOffset( 4,4,4,4 );
            Rect rect = GUILayoutUtility.GetRect( 0.0f,0.0f,GUILayout.ExpandWidth(true),GUILayout.Height(32.0f + margin.vertical) );

            int controlID = GUIUtility.GetControlID( property.gameObject.GetInstanceID(),FocusType.Passive,rect );

            bool selected = Selection.gameObjects.Contains(property.gameObject);

            if( selected )
            {
                Color[] darkColors = new Color[]{
                    new Color32( 72,72,72,255 ),
                    new Color32( 62,95,150,255 )
                };
                Color[] lightColors = new Color[]{
                    new Color32( 142,142,142,255 ),
                    new Color32( 62,124,230,255 )
                };

                Color[] colors = !EditorGUIUtility.isProSkin ? lightColors : darkColors;
                Color color = focused ? colors[1] : colors[0];

                EditorGUI.DrawRect( rect,color );
            }

            rect = margin.Remove( rect );

            Rect activeRect = new Rect( rect );
            activeRect.y = rect.y+rect.height*0.5f-16.0f;
            activeRect.width = 16.0f;
            activeRect.height = 16.0f;

            EditorGUI.BeginChangeCheck();
            bool active = EditorGUI.Toggle( activeRect,property.active );
            if( EditorGUI.EndChangeCheck() )
            {
                property.active = active;
            }

            Rect visibleRect = new Rect( rect );
            visibleRect.y = rect.y+rect.height*0.5f;
            visibleRect.width = 16.0f;
            visibleRect.height = 16.0f;

            EditorGUI.BeginChangeCheck();
            bool enabled = EditorGUI.Toggle( visibleRect,property.enabled,Styles.visiblyToggle );
            if( EditorGUI.EndChangeCheck() )
            {
                property.enabled = enabled;
            }

            Rect previewRect = new Rect( rect );

            previewRect.x += 16.0f;
            previewRect.width = 32.0f;
            previewRect.height = 32.0f;

            property.OnPreviewGUI( previewRect,GUI.skin.box );

            if( Event.current.type == EventType.Repaint )
            {
                GUIContent label = new GUIContent( property.name );
                GUIContent orderContent = new GUIContent( property.sortingOrder.ToString() );

                GUIStyle labelStyle = Styles.hiLabel;
                GUIStyle orderStyle = Styles.rightLabel;

                Rect labelRect = new Rect( rect );

                labelRect.x += 48.0f;
                labelRect.width -= 100.0f - 48.0f;

                float labelHeight = labelStyle.CalcHeight(label,labelRect.width);
                labelRect.y += (labelRect.height-labelHeight )*0.5f;
                labelRect.height = labelHeight;

                Rect orderRect = new Rect( rect );

                orderRect.x = rect.xMax - 100.0f;
                orderRect.width = 100.0f;

                float orderHeight = orderStyle.CalcHeight(orderContent,orderRect.width);
                orderRect.y += (orderRect.height-orderHeight )*0.5f;
                orderRect.height = orderHeight;

                Color[] colorArray = !EditorGUIUtility.isProSkin ? s_HierarchyColors : s_DarkColors;

                int colorCode = property.colorCode;
                Color color = colorArray[colorCode & 3];
                Color onColor = colorArray[(colorCode & 3) + 4];
                color.a = colorCode < 4 ? (onColor.a = 1f) : (onColor.a = 0.6f);

                labelStyle.normal.textColor = color;
                labelStyle.focused.textColor = color;
                labelStyle.hover.textColor = color;
                labelStyle.active.textColor = color;
                labelStyle.onNormal.textColor = onColor;
//.........这里部分代码省略.........
开发者ID:sgmtjp,项目名称:Git-SODATERUTOWER,代码行数:101,代码来源:SortingLayerWindow.cs

示例3: DrawInspectedRect

 protected void DrawInspectedRect(Rect instructionRect)
 {
     Rect rect = GUILayoutUtility.GetRect((float) 0f, (float) 100f);
     int top = Mathf.CeilToInt(34f);
     int bottom = Mathf.CeilToInt(16f);
     int right = 100;
     RectOffset offset = new RectOffset(50, right, top, bottom);
     Rect position = offset.Remove(rect);
     float imageAspect = instructionRect.width / instructionRect.height;
     Rect outScreenRect = new Rect();
     Rect outSourceRect = new Rect();
     GUI.CalculateScaledTextureRects(position, ScaleMode.ScaleToFit, imageAspect, ref outScreenRect, ref outSourceRect);
     position = outScreenRect;
     position.width = Mathf.Max(80f, position.width);
     position.height = Mathf.Max(26f, position.height);
     Rect rect5 = new Rect {
         height = 16f,
         width = offset.left * 2,
         y = position.y - offset.top
     };
     rect5.x = position.x - (rect5.width / 2f);
     Rect rect7 = new Rect {
         height = 16f,
         width = offset.right * 2,
         y = position.yMax
     };
     Rect rect6 = rect7;
     rect6.x = position.xMax - (rect6.width / 2f);
     rect7 = new Rect {
         x = position.x,
         y = rect5.yMax + 2f,
         width = position.width,
         height = 16f
     };
     Rect rect8 = rect7;
     Rect rect9 = rect8;
     rect9.width = rect8.width / 3f;
     rect9.x = rect8.x + ((rect8.width - rect9.width) / 2f);
     Rect rect10 = position;
     rect10.x = position.xMax;
     rect10.width = 16f;
     Rect rect11 = rect10;
     rect11.height = 16f;
     rect11.width = offset.right;
     rect11.y += (rect10.height - rect11.height) / 2f;
     GUI.Label(rect5, string.Format("({0},{1})", instructionRect.x, instructionRect.y), this.styles.centeredLabel);
     Handles.color = new Color(1f, 1f, 1f, 0.5f);
     Vector3 vector = new Vector3(rect8.x, rect9.y);
     Vector3 vector2 = new Vector3(rect8.x, rect9.yMax);
     Handles.DrawLine(vector, vector2);
     vector.x = vector2.x = rect8.xMax;
     Handles.DrawLine(vector, vector2);
     vector.x = rect8.x;
     vector.y = vector2.y = Mathf.Lerp(vector.y, vector2.y, 0.5f);
     vector2.x = rect9.x;
     Handles.DrawLine(vector, vector2);
     vector.x = rect9.xMax;
     vector2.x = rect8.xMax;
     Handles.DrawLine(vector, vector2);
     GUI.Label(rect9, instructionRect.width.ToString(), this.styles.centeredLabel);
     vector = new Vector3(rect10.x, rect10.y);
     vector2 = new Vector3(rect10.xMax, rect10.y);
     Handles.DrawLine(vector, vector2);
     vector.y = vector2.y = rect10.yMax;
     Handles.DrawLine(vector, vector2);
     vector.x = vector2.x = Mathf.Lerp(vector.x, vector2.x, 0.5f);
     vector.y = rect10.y;
     vector2.y = rect11.y;
     Handles.DrawLine(vector, vector2);
     vector.y = rect11.yMax;
     vector2.y = rect10.yMax;
     Handles.DrawLine(vector, vector2);
     GUI.Label(rect11, instructionRect.height.ToString());
     GUI.Label(rect6, string.Format("({0},{1})", instructionRect.xMax, instructionRect.yMax), this.styles.centeredLabel);
     GUI.Box(position, GUIContent.none);
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:76,代码来源:BaseInspectView.cs


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