/// <summary>
        /// コライダー描画
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="pivot"></param>
        /// <param name="pan"></param>
        /// <param name="mouse"></param>
        /// <param name="scale"></param>
        public void DrawColliderRects(Vector2 pos, Vector2 pivot, Vector2 mouse, float scale)
        {
            UpdateSerializedObject();

            if (Animations == null || SelectedAnimation >= Animations.Length ||
                Animations[SelectedAnimation].frameData == null || SelectedFrame >= Animations[SelectedAnimation].frameData.Length)
            {
                return;
            }
            var framedata     = Animations[SelectedAnimation].frameData[SelectedFrame];
            var colliderArray = framedata.collider;
            var eventType     = Event.current.type;
            var eventButton   = Event.current.button;

            m_EditorScale   = scale;
            m_PreviewOrigin = pos;

            for (int i = 0; i < colliderArray.Length; i++)
            {
                var collider = colliderArray[i];
                var color    = HitboxSettings.COLOR(collider.type);

                color.a               = 0.75f;
                collider.rect.x      *= (int)scale;
                collider.rect.y      *= (int)scale;
                collider.rect.width  *= (int)scale;
                collider.rect.height *= (int)scale;

                Rect rect = new Rect(collider.rect.x - collider.rect.width / 2,
                                     collider.rect.y + collider.rect.height / 2,
                                     collider.rect.width,
                                     collider.rect.height);

                if (m_Renderer != null && m_Renderer.flipX)
                {
                    rect.x     *= -1;
                    rect.width *= -1;
                }

                var cRect = new Rect(pos.x + (rect.x), pos.y - (rect.y), rect.width, rect.height);

                if (i != SelectedCollider)
                {
                    if (m_MouseOverHandle == null && m_ActiveHandle == null && cRect.Contains(mouse))
                    {
                        color.a = 0.5f;

                        if (eventType == EventType.MouseDown)
                        {
                            if (eventButton < 2)
                            {
                                SelectedCollider = i;
                            }
                            if (eventButton == 1)
                            {
                                CreateColliderEditMenu(mouse);
                            }
                            else if (eventButton == 0)
                            {
                                m_isEditorMenuOpen = false;
                            }

                            return;
                        }
                    }
                    else
                    {
                        color.a = 0.25f;
                    }
                }

                if (eventType == EventType.Repaint)
                {
                    EditorGUI.DrawRect(cRect, color);
                }

                //If we are editing this collider we need to display the editor doo dads
                if (SelectedCollider == i)
                {
                    m_MouseOverHandle = null;

                    if (m_ColliderDragHandle[0].Draw(new Vector2(cRect.x, cRect.y), mouse, MouseCursor.ResizeUpLeft))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[0];
                    }

                    if (m_ColliderDragHandle[1].Draw(new Vector2(cRect.x + cRect.width / 2f, cRect.y), mouse, MouseCursor.ResizeVertical))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[1];
                    }

                    if (m_ColliderDragHandle[2].Draw(new Vector2(cRect.x + cRect.width, cRect.y), mouse, MouseCursor.ResizeUpRight))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[2];
                    }

                    if (m_ColliderDragHandle[3].Draw(new Vector2(cRect.x + cRect.width, cRect.y + cRect.height / 2f), mouse, MouseCursor.ResizeHorizontal))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[3];
                    }

                    if (m_ColliderDragHandle[4].Draw(new Vector2(cRect.x + cRect.width, cRect.y + cRect.height), mouse, MouseCursor.ResizeUpLeft))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[4];
                    }

                    if (m_ColliderDragHandle[5].Draw(new Vector2(cRect.x + cRect.width / 2f, cRect.y + cRect.height), mouse, MouseCursor.ResizeVertical))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[5];
                    }

                    if (m_ColliderDragHandle[6].Draw(new Vector2(cRect.x, cRect.y + cRect.height), mouse, MouseCursor.ResizeUpRight))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[6];
                    }

                    if (m_ColliderDragHandle[7].Draw(new Vector2(cRect.x, cRect.y + cRect.height / 2f), mouse, MouseCursor.ResizeHorizontal))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[7];
                    }

                    if (m_ColliderDragHandle[8].Draw(new Vector2(cRect.x + cRect.width / 2f, cRect.y + cRect.height / 2f), mouse, MouseCursor.Pan))
                    {
                        m_MouseOverHandle = m_ColliderDragHandle[8];
                    }

                    if (eventType == EventType.Repaint)
                    {
                        LabelDrawer.DrawLabel(collider.type.ToString(), new Vector2(cRect.x + 4, cRect.y + 4));
                        LabelDrawer.DrawLabel("X: " + colliderArray[i].rect.x, new Vector2(cRect.x + 4, cRect.y + 22), 10);
                        LabelDrawer.DrawLabel("Y: " + colliderArray[i].rect.y, new Vector2(cRect.x + 4, cRect.y + 34), 10);
                        LabelDrawer.DrawLabel("W: " + colliderArray[i].rect.width, new Vector2(cRect.x + 4, cRect.y + 46), 10);
                        LabelDrawer.DrawLabel("H: " + colliderArray[i].rect.height, new Vector2(cRect.x + 4, cRect.y + 58), 10);
                    }

                    if (eventType == EventType.MouseDown)
                    {
                        if (m_MouseOverHandle != null && eventButton == 0)
                        {
                            m_ActiveHandle = m_MouseOverHandle;
                        }
                        else if (m_isEditorMenuOpen == false && eventButton == 1 && cRect.Contains(mouse))
                        {
                            CreateColliderEditMenu(mouse);
                        }
                    }
                    else if (eventType == EventType.MouseUp && eventButton == 0)
                    {
                        m_ActiveHandle = null;
                    }
                    else if (eventType == EventType.MouseDrag && m_ActiveHandle != null)
                    {
                        var delta = m_ActiveHandle.GetDragRect(mouse) / scale;

                        colliderArray[SelectedCollider].rect.x      += Mathf.RoundToInt(delta.x);
                        colliderArray[SelectedCollider].rect.y      += Mathf.RoundToInt(delta.y);
                        colliderArray[SelectedCollider].rect.width  += Mathf.RoundToInt(delta.z);
                        colliderArray[SelectedCollider].rect.height += Mathf.RoundToInt(delta.w);
                    }
                }
            }

            if (m_isEditorMenuOpen == false && eventType == EventType.MouseDown && eventButton == 1)
            {
                CreateEditMenu(mouse);
            }

            ApplySerializedProperties();
        }
        /// <summary>
        /// ギズモ描画
        /// </summary>
        /// <param name="position"></param>
        /// <param name="pivot"></param>
        /// <param name="mouse"></param>
        /// <param name="scale"></param>
        public void DrawEditorGizmos(Vector2 position, Vector2 pivot, Vector2 mouse, float scale)
        {
            UpdateSerializedObject();

            if (Animations == null ||
                SelectedAnimation >= Animations.Length ||
                Animations[SelectedAnimation].frameData == null ||
                SelectedFrame >= Animations[SelectedAnimation].frameData.Length)
            {
                return;
            }

            var framedata   = Animations[SelectedAnimation].frameData[SelectedFrame];
            var eventType   = Event.current.type;
            var eventButton = Event.current.button;

            m_EditorScale   = scale;
            m_PreviewOrigin = position;

            if (framedata.events != null)
            {
                int currGizmo = 0;

                for (int i = 0; i < framedata.events.Length; i++)
                {
                    if (framedata.events[i].id.ToString().Contains(PROJECTILE))
                    {
                        var origin = IntConverter.DecodeIntToVector2(framedata.events[i].intParam) * scale;
                        var dest   = IntConverter.DecodeIntToVector2((int)framedata.events[i].floatParam) * scale;

                        m_MouseOverHandle = null;
                        //If the dots are overlapping we're going to force them apart
                        if (dest == origin)
                        {
                            dest.x += 20 * scale;
                        }

                        if (eventType == EventType.Repaint)
                        {
                            var a         = new Vector2(-1f, 1f);
                            var b         = new Vector2(-1f, -1f);
                            var direction = Vector3.Normalize(dest - origin);
#if UNITY_2017_1_OR_NEWER
                            var rotation = Quaternion.AngleAxis(Vector2.SignedAngle(direction, Vector2.right), -Vector3.forward);
#else
                            var angle    = Vector2.Angle(direction, Vector2.right);
                            var cross    = Vector3.Cross(direction, Vector3.right);
                            var rotation = Quaternion.AngleAxis(cross.z < 0 ? -angle : angle, -Vector3.forward);
#endif
                            a = rotation * a;
                            b = rotation * b;

                            LineDrawer.DrawLine(origin + position, dest + position, 6, Color.black);
                            LineDrawer.DrawLine(dest + position, dest + position + a * 11f, 6, Color.black);
                            LineDrawer.DrawLine(dest + position, dest + position + b * 11f, 6, Color.black);

                            LineDrawer.DrawLine(origin + position, dest + position, 4, Color.white);
                            LineDrawer.DrawLine(dest + position, dest + position + a * 10f, 4, Color.white);
                            LineDrawer.DrawLine(dest + position, dest + position + b * 10f, 4, Color.white);

                            LabelDrawer.DrawLabel(framedata.events[i].id.ToString(), origin + position + new Vector2(0f, 6f));
                        }

                        if (m_GizmoDragHandle[currGizmo * 2 + 0].Draw(position + origin, mouse, MouseCursor.Pan))
                        {
                            var index = i;
                            m_GizmoDragHandle[currGizmo * 2 + 0].action = (Vector2 v) =>
                                                                          Animations[SelectedAnimation].frameData[SelectedFrame].events[index].intParam = IntConverter.EncodeVector2ToInt(v / scale);
                            m_MouseOverHandle = m_GizmoDragHandle[currGizmo * 2 + 0];
                        }
                        if (m_GizmoDragHandle[currGizmo * 2 + 1].Draw(position + dest, mouse, MouseCursor.Pan))
                        {
                            var index = i;
                            m_GizmoDragHandle[currGizmo * 2 + 1].action = (Vector2 v) =>
                                                                          Animations[SelectedAnimation].frameData[SelectedFrame].events[index].floatParam = IntConverter.EncodeVector2ToInt(v / scale);
                            m_MouseOverHandle = m_GizmoDragHandle[currGizmo * 2 + 1];
                        }

                        if (eventType == EventType.MouseDown && m_MouseOverHandle != null && eventButton == 0)
                        {
                            m_ActiveHandle = m_MouseOverHandle;
                            //remove this click from the event so we don't click through other gizmos beneath us.
                            eventButton = 3;
                        }
                        else if (eventType == EventType.MouseUp && eventButton == 0)
                        {
                            m_ActiveHandle = null;
                        }
                        else if (eventType == EventType.MouseDrag && m_ActiveHandle != null && m_ActiveHandle.action != null)
                        {
                            m_ActiveHandle.action(mouse - position);
                        }

                        currGizmo++;
                    }
                }
            }

            if (m_PivotHandle.Draw(m_ActiveHandle == m_PivotHandle ? mouse : position, mouse, MouseCursor.Pan) &&
                m_ActiveHandle == null)
            {
                m_MouseOverHandle = m_PivotHandle;
            }
            else if (m_MouseOverHandle == m_PivotHandle)
            {
                m_MouseOverHandle = null;
            }

            // if (m_ActiveHandle == null && m_MouseOverHandle == m_PivotHandle && eventType == EventType.MouseDown && eventButton == 0)
            // {
            //     m_ActiveHandle = m_MouseOverHandle;
            // }
            // else if (m_ActiveHandle != null && m_ActiveHandle == m_PivotHandle && eventType == EventType.MouseUp)
            // {
            //     if (m_Renderer == null)
            //         m_Renderer = m_targetManager.GetComponent<SpriteRenderer>();
            //     var path = AssetDatabase.GetAssetPath(m_Renderer.sprite);
            //     TextureImporter import = (TextureImporter)AssetImporter.GetAtPath(path);
            //     if (import.spriteImportMode == SpriteImportMode.Multiple && import.spritesheet != null)
            //     {
            //         var metadata = import.spritesheet;
            //         import.isReadable = true;
            //         for (int i = 0; i < metadata.Length; i++)
            //             if (metadata[i].name.Equals(m_Renderer.sprite.name))
            //             {
            //                 var p = (mouse - (position - pivot)) / scale;
            //                 p.x = Mathf.Round(p.x) / metadata[i].rect.width;
            //                 p.y = 1f - (Mathf.Round(p.y) / metadata[i].rect.height);
            //                 metadata[i].pivot = p;
            //                 break;
            //             }
            //         m_ActiveHandle = m_MouseOverHandle = null;
            //         import.spritesheet = metadata;
            //         EditorUtility.SetDirty(import);
            //         import.SaveAndReimport();
            //     }
            //     m_ActiveHandle = m_MouseOverHandle = null;
            // }

            Vector2 alignedPos = (m_ActiveHandle == m_PivotHandle)
                ? mouse - (position - pivot)
                : pivot;

            string labelText = "Pivot (" + Mathf.RoundToInt(alignedPos.x / scale)
                               + ", " + Mathf.RoundToInt(alignedPos.y / scale) + ")";
            Vector2 labelPos = (m_ActiveHandle == m_PivotHandle)
                ? mouse
                : position;
            labelPos += new Vector2(-15f, 6f);
            LabelDrawer.DrawLabel(labelText, labelPos);

            if (m_isEditorMenuOpen == false && eventType == EventType.MouseDown && eventButton == 1)
            {
                if (m_Renderer == null)
                {
                    m_Renderer = m_targetManager.GetComponent <SpriteRenderer>();
                }

                var size        = m_Renderer.sprite.rect.size;
                var pivotPixels = m_Renderer.sprite.pivot;

                CreateEditGizmoMenu(new Vector2(pivotPixels.x / size.x, pivotPixels.y / size.y), mouse);
            }

            ApplySerializedProperties();
        }