public override void OnInspectorGUI()
    {
        tk2dClippedSprite sprite = (tk2dClippedSprite)target;

        base.OnInspectorGUI();

        if (sprite.CurrentSprite == null)
        {
            return;
        }

        var spriteData = sprite.GetCurrentSpriteDef();

        if (spriteData != null)
        {
            WarnSpriteRenderType(spriteData);
        }

        bool newCreateBoxCollider = base.DrawCreateBoxColliderCheckbox(sprite.CreateBoxCollider);

        if (newCreateBoxCollider != sprite.CreateBoxCollider)
        {
            sprite.CreateBoxCollider = newCreateBoxCollider;
            if (sprite.CreateBoxCollider)
            {
                sprite.EditMode__CreateCollider();
            }
        }

        Rect newClipRect = EditorGUILayout.RectField("Clip Region", sprite.ClipRect);

        if (newClipRect != sprite.ClipRect)
        {
            tk2dUndo.RecordObjects(targetClippedSprites, "Clipped Sprite Rect");
            foreach (tk2dClippedSprite spr in targetClippedSprites)
            {
                spr.ClipRect = newClipRect;
            }
        }

        showSceneClipControl = EditorGUILayout.Toggle("Edit Region in Scene", showSceneClipControl);

        EditorGUI.indentLevel--;

        if (GUI.changed)
        {
            foreach (tk2dClippedSprite spr in targetClippedSprites)
            {
                EditorUtility.SetDirty(spr);
            }
        }
    }
    public override void OnInspectorGUI()
    {
        tk2dClippedSprite sprite = (tk2dClippedSprite)target;

        base.OnInspectorGUI();

        if (sprite.CurrentSprite == null)
        {
            return;
        }

        var spriteData = sprite.GetCurrentSpriteDef();

        if (spriteData != null)
        {
            WarnSpriteRenderType(spriteData);
        }

        bool newCreateBoxCollider = EditorGUILayout.Toggle("Create Box Collider", sprite.CreateBoxCollider);

        if (newCreateBoxCollider != sprite.CreateBoxCollider)
        {
            Undo.RegisterUndo(targetClippedSprites, "Create Box Collider");
            if (newCreateBoxCollider)
            {
                sprite.boxCollider = sprite.GetComponent <BoxCollider>();
                if (sprite.boxCollider == null)
                {
                    sprite.boxCollider = sprite.gameObject.AddComponent <BoxCollider>();
                }
            }
            else
            {
                var boxCollider = sprite.GetComponent <BoxCollider>();
                if (boxCollider != null)
                {
                    DestroyImmediate(boxCollider);
                }
                sprite.boxCollider = null;
            }
            sprite.CreateBoxCollider = newCreateBoxCollider;
        }

        Rect newClipRect = EditorGUILayout.RectField("Clip Region", sprite.ClipRect);

        if (newClipRect != sprite.ClipRect)
        {
            Undo.RegisterUndo(targetClippedSprites, "Clipped Sprite Rect");
            foreach (tk2dClippedSprite spr in targetClippedSprites)
            {
                spr.ClipRect = newClipRect;
            }
        }

        showSceneClipControl = EditorGUILayout.Toggle("Edit Region in Scene", showSceneClipControl);

        EditorGUI.indentLevel--;

        if (GUI.changed)
        {
            foreach (tk2dClippedSprite spr in targetClippedSprites)
            {
                EditorUtility.SetDirty(spr);
            }
        }
    }