예제 #1
0
 public void Clear_Attachment(bool bCanUndo)
 {
     Iso2DObject[] _iso2Ds = transform.GetComponentsInChildren <Iso2DObject>();
     for (int i = 0; i < _iso2Ds.Length; ++i)
     {
         Iso2DObject _iso2D = _iso2Ds[i];
         if (_iso2D != null && _iso2D.IsAttachment)
         {
             _iso2D.DestoryGameObject(bCanUndo, false);
         }
     }
 }
예제 #2
0
        public void Toggle_Side(bool _bToggle, Iso2DObject.Type _toggleType)
        {
            Iso2DObject _obj = GetSideObject(_toggleType);

            if (_bToggle)
            {
                if (_obj == null)
                {
                    Add_SideObject(IsoMap.GetSidePrefab(_toggleType),
                                   "Created : " + _toggleType + " Object");
                }
            }
            else
            {
                if (_obj != null)
                {
                    _obj.DestoryGameObject(true, true);
                    Update_AttachmentList();
                }
            }
        }
예제 #3
0
        public static void Drawer(Rect rect, GameObject _target)
        {
            IsoTile        _thisTile   = _target.GetComponent <IsoTile>();
            Iso2DObject    _iso2D      = _target.GetComponent <Iso2DObject>();
            SpriteRenderer sprr        = _target.GetComponent <SpriteRenderer>();
            Color          borderColor = Util.CustomEditorGUI.Color_Tile;

            if (_thisTile == null && _iso2D != null)
            {
                borderColor = CustomEditorGUI.Iso2DTypeColor(_iso2D._Type);
            }

            Rect rect_inside = new Rect(rect.xMin + border, rect.yMin + border, rect.width - border * 2, rect.height - border * 2);

            Rect rect_preview   = new Rect(rect_inside.xMin, rect_inside.yMin, cellSize, rect_inside.height);
            Rect rect_info_name =
                new Rect(rect_preview.xMax, rect_inside.yMin,
                         rect_inside.width - cellSize - fudgeWidth, rect_inside.height * 0.5f);
            Rect rect_Fudge =
                new Rect(rect_info_name.xMax, rect_inside.yMin,
                         fudgeWidth, rect_inside.height * 0.5f - border);
            Rect rect_info_Sub =
                new Rect(rect_info_name.xMin, rect_info_name.yMin + cellSize * 0.5f,
                         rect_info_name.width, rect_inside.height - rect_info_name.height);

            Rect[] rect_btns = new Rect[]
            {
                new Rect(rect_inside.xMax - cellSize * 1.1f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height),
                new Rect(rect_inside.xMax - cellSize * 2.2f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height),
                new Rect(rect_inside.xMax - cellSize * 3.3f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height),
                new Rect(rect_inside.xMax - cellSize * 4.4f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height)
            };

            bool bControllerable = (_thisTile == null || _thisTile.gameObject != _target.gameObject) ||
                                   (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent <IsoTileBulk>());

            CustomEditorGUI.DrawBordereddRect(rect, borderColor, rect_inside, Color.clear);
            CustomEditorGUI.DrawSideSprite(rect_preview, _iso2D, false, false);

            int iLv = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            EditorGUI.LabelField(rect_info_name, _target.name, EditorStyles.boldLabel);

            if (!IsoMap.instance.bUseIsometricSorting)
            {
                var IIsoBasis        = _iso2D.GetComponentInParent <IISOBasis>();
                var isOnGroundObject = false;
                if (IIsoBasis != null)
                {
                    isOnGroundObject = IIsoBasis.IsOnGroundObject();
                }
                else
                {
                    isOnGroundObject = _iso2D.IsColliderAttachment;
                }
                float  fOnGroundOffset = IsoMap.fCurrentOnGroundOffset;
                string msg             = isOnGroundObject ? string.Format("Depth({0:0.00})", -fOnGroundOffset) : "Depth";
                float  _fTmp           = CustomEditorGUI.FloatSlider(rect_Fudge, msg, _iso2D.FDepthFudge, -1f, 1f);
                if (_fTmp != _iso2D.FDepthFudge)
                {
                    _iso2D.Undo_NewDepthFudge(_fTmp);
                }
            }
            // 서브 인포 출력
            //using (new EditorGUILayout.HorizontalScope())
            {
                float            _fMinSize = Mathf.Min(rect_info_Sub.width, rect_info_Sub.height);
                SpriteRenderer[] _sprrList = _target.GetComponentsInChildren <SpriteRenderer>();

                for (int i = 0; i < _sprrList.Length; ++i)
                {
                    if (_sprrList[i].sprite != null && _sprrList[i] != sprr)
                    {
                        Rect _rt = EditorGUI.IndentedRect(rect_info_Sub);
                        _rt.width           = _rt.height = _fMinSize;
                        rect_info_Sub.xMin += _fMinSize;
                        // CustomEditorGUI.DrawSideSprite(_rt, _sprrList[i].sprite, ._Type);
                        Util.CustomEditorGUI.DrawSprite(_rt, _sprrList[i].sprite, _sprrList[i].color, true, true);
                    }
                }
            }
            if (bControllerable)
            {
                int buttonIndex = 0;
                CustomEditorGUI.Button(rect_btns[buttonIndex++], true, CustomEditorGUI.Color_LightYellow, "Ping!",
                                       () => { EditorGUIUtility.PingObject(_target.gameObject); });

                CustomEditorGUI.Button(rect_btns[buttonIndex++], true, CustomEditorGUI.Color_LightGreen, "Iso2D",
                                       () => { Selection.activeGameObject = _target.gameObject; });

                var ctlr = _target.transform.parent.GetComponentInParent <SubColliderHelper>();
                if (Selection.activeGameObject != ctlr.gameObject)
                {
                    CustomEditorGUI.Button(rect_btns[buttonIndex++], true, CustomEditorGUI.Color_LightGreen, "Ctlr!",
                                           () => { Selection.activeGameObject = ctlr.gameObject; });
                }

                CustomEditorGUI.Button(rect_btns[buttonIndex++].ReSize(2f, 2f), true, CustomEditorGUI.Color_LightYellow, "Del!!",
                                       () => { _iso2D.DestoryGameObject(true, true); });
            }
            EditorGUI.indentLevel = iLv;
        }
예제 #4
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (Event.current.type == EventType.ScrollWheel)
            {
                return;
            }

            SerializedProperty sp = property.serializedObject.FindProperty(property.propertyPath);

            if (sp != property)
            {
                sp = property;
            }
            if (sp.objectReferenceValue == null)
            {
                return;
            }

            GameObject     _target     = ((Component)sp.objectReferenceValue).gameObject;
            IsoTile        _thisTile   = _target.GetComponent <IsoTile>();
            Iso2DObject    _iso2D      = _target.GetComponent <Iso2DObject>();
            SpriteRenderer sprr        = _target.GetComponent <SpriteRenderer>();
            Color          borderColor = Util.CustomEditorGUI.Color_Tile;

            if (_thisTile == null && _iso2D != null)
            {
                switch (_iso2D._Type)
                {
                case Iso2DObject.Type.Obstacle:
                    borderColor = Util.CustomEditorGUI.Color_Obstacle;
                    break;

                case Iso2DObject.Type.Overlay:
                    borderColor = Util.CustomEditorGUI.Color_Overlay;
                    break;

                case Iso2DObject.Type.Side_Union:
                case Iso2DObject.Type.Side_X:
                case Iso2DObject.Type.Side_Y:
                case Iso2DObject.Type.Side_Z:
                    borderColor = Util.CustomEditorGUI.Color_Tile;
                    break;

                default:
                    borderColor = Util.CustomEditorGUI.Color_Side;
                    break;
                }
            }

            if (sprr == null)
            {
                GUILayout.Label("Empty Bulk", EditorStyles.objectFieldThumb);
                return;
            }

            Rect rect        = position;
            Rect rect_inside = new Rect(rect.xMin + border, rect.yMin + border, rect.width - border * 2, rect.height - border * 2);

            Rect rect_preview   = new Rect(rect_inside.xMin, rect_inside.yMin, cellSize, rect_inside.height);
            Rect rect_info_name =
                new Rect(rect_preview.xMax, rect_inside.yMin,
                         rect_inside.width - cellSize - fudgeWidth, rect_inside.height * 0.5f);
            Rect rect_Fudge =
                new Rect(rect_info_name.xMax, rect_inside.yMin,
                         fudgeWidth, rect_inside.height * 0.5f - border);
            Rect rect_info_Sub =
                new Rect(rect_info_name.xMin, rect_info_name.yMin + cellSize * 0.5f,
                         rect_info_name.width, rect_inside.height - rect_info_name.height);
            Rect rect_delete =
                new Rect(rect_inside.xMax - cellSize * 3.3f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height);
            Rect rect_select_ctlr =
                new Rect(rect_inside.xMax - cellSize * 2.2f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height);
            Rect rect_select_go =
                new Rect(rect_inside.xMax - cellSize * 1.1f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height);

            bool bControllerable = (_thisTile == null || _thisTile.gameObject != _target.gameObject) ||
                                   (Selection.activeGameObject != null &&
                                    Selection.activeGameObject.GetComponent <IsoTileBulk>());

            EditorGUI.DrawRect(rect, borderColor);
            EditorGUI.DrawRect(rect_inside, new Color(0.8f, 0.8f, 0.8f));

            CustomEditorGUI.DrawSideSprite(rect_preview, _iso2D, false, false);

            int iLv = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            EditorGUI.LabelField(rect_info_name, _target.name, EditorStyles.boldLabel);

            float _fTmp = CustomEditorGUI.FloatSlider(rect_Fudge, "Depth", _iso2D.fDepthFudge, -1f, 1f);

            if (_fTmp != _iso2D.fDepthFudge)
            {
                _iso2D.Undo_DepthFudge(_fTmp);
            }
            // 서브 인포 출력
            //using (new EditorGUILayout.HorizontalScope())
            {
                float            _fMinSize = Mathf.Min(rect_info_Sub.width, rect_info_Sub.height);
                SpriteRenderer[] _sprrList = _target.GetComponentsInChildren <SpriteRenderer>();

                for (int i = 0; i < _sprrList.Length; ++i)
                {
                    if (_sprrList[i].sprite != null && _sprrList[i] != sprr)
                    {
                        Rect _rt = EditorGUI.IndentedRect(rect_info_Sub);
                        _rt.width           = _rt.height = _fMinSize;
                        rect_info_Sub.xMin += _fMinSize;
                        // CustomEditorGUI.DrawSideSprite(_rt, _sprrList[i].sprite, ._Type);
                        Util.CustomEditorGUI.DrawSprite(_rt, _sprrList[i].sprite, _sprrList[i].color, true, true);
                    }
                }
            }
            if (bControllerable)
            {
                RegularCollider ctlr = _target.transform.parent.GetComponentInParent <RegularCollider>();
                if (Selection.activeGameObject == ctlr.gameObject)
                {
                    ctlr = null;
                }
                using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightYellow))
                {
                    if (GUI.Button((ctlr != null ? rect_delete : rect_select_ctlr).ReSize(2f, 2f), "Del!"))
                    {
                        _iso2D.DestoryGameObject(true, true);
                    }
                }
                if (ctlr != null)
                {
                    using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightMagenta))
                    {
                        if (GUI.Button(rect_select_ctlr, "Ctlr"))
                        {
                            Selection.activeGameObject = ctlr.gameObject;
                        }
                    }
                }
                using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightMagenta))
                {
                    if (GUI.Button(rect_select_go, "Iso2D"))
                    {
                        Selection.activeGameObject = _target.gameObject;
                    }
                }
            }
            EditorGUI.indentLevel = iLv;
        }