示例#1
0
    private Hitbox DrawMove(Hitbox currentHitbox, TargetComponents targetComponents)
    {
        Vector3 handlePosition = currentHitbox.GetHandlePosition();
        Vector3 moveHandlePos = Handles.FreeMoveHandle(handlePosition + targetComponents.GameObject.transform.position, Quaternion.identity, 0.05f, Vector3.one, Handles.RectangleCap);
        moveHandlePos -= targetComponents.GameObject.transform.position;

        currentHitbox.Boundaries = new Rect(moveHandlePos.x, moveHandlePos.y,
                                                currentHitbox.Boundaries.width,
                                                currentHitbox.Boundaries.height);

        return currentHitbox;
    }
示例#2
0
    private void OnLostFocus()
    {
        EditorApplication.update -= OnEditorUpdate;

        if (targetComponents.SpriteRenderer != null)
        {
            //TODO check why not working
            targetComponents.SpriteRenderer.sprite = targetComponents.spriteWhenGotFocus;
            targetComponents = null;
            serializedObject.Update();
            serializedObject.ApplyModifiedProperties();
        }
    }
示例#3
0
    private Hitbox DrawMove(Hitbox currentHitbox, TargetComponents targetComponents)
    {
        Vector3 handlePosition = currentHitbox.GetHandlePosition();
        Vector3 moveHandlePos  = Handles.FreeMoveHandle(handlePosition + targetComponents.GameObject.transform.position, Quaternion.identity, 0.05f, Vector3.one, Handles.RectangleCap);

        moveHandlePos -= targetComponents.GameObject.transform.position;

        currentHitbox.Boundaries = new Rect(moveHandlePos.x, moveHandlePos.y,
                                            currentHitbox.Boundaries.width,
                                            currentHitbox.Boundaries.height);

        return(currentHitbox);
    }
示例#4
0
    public Hitbox DrawSceneHandle(Hitbox hitbox, TargetComponents targetComponents)
    {
        if (Tools.current == Tool.Move)
        {
            return(DrawMove(hitbox, targetComponents));
        }
        else if (Tools.current == Tool.Scale)
        {
            return(DrawScale(hitbox, targetComponents));
        }

        return(hitbox);
    }
示例#5
0
    public Hitbox DrawSceneHandle(Hitbox hitbox, TargetComponents targetComponents)
    {
        if (Tools.current == Tool.Move)
        {
            return DrawMove(hitbox, targetComponents);
        }
        else if (Tools.current == Tool.Scale)
        {
            return DrawScale(hitbox, targetComponents);
        }

        return hitbox;
    }
示例#6
0
    void OnEnable()
    {
        EditorApplication.update += OnEditorUpdate;

        if (hitboxBackgroundStyle == null)
        {
            hitboxBackgroundStyle = new GUIStyle();
            hitboxBackgroundStyle.normal.background = MakeTexture(1, 1, new Color(0f, 0f, 0f, 0.2f));
        }
        //When changing scenes the background is deleted
        else if (hitboxBackgroundStyle.normal.background == null)
        {
            hitboxBackgroundStyle.normal.background = MakeTexture(1, 1, new Color(0f, 0f, 0f, 0.2f));
        }

        targetComponents      = new TargetComponents(target);
        zeroHitboxClipsFeeder = new ZeroHitBoxClipsFeeder(targetComponents.ZeroHitbox);

        zeroHitboxClipsFeeder.FeedAnimationClips(targetComponents.Animator);

        //TODO maybe get previously set value?
        keyframesIndex      = 0;
        animationClipsIndex = 0;
    }
示例#7
0
    private Hitbox DrawScale(Hitbox currentHitbox, TargetComponents targetComponents)
    {
        Vector3 ScaleHandleXPos;
        Vector3 ScaleHandleYPos;

        ScaleHandleXPos = Handles.FreeMoveHandle(currentHitbox.GetHandleXScale() + targetComponents.GameObject.transform.position,
                                                 Quaternion.identity,
                                                 0.05f,
                                                 Vector3.one,
                                                 Handles.DotCap);
        ScaleHandleXPos -= targetComponents.GameObject.transform.position;

        ScaleHandleYPos = Handles.FreeMoveHandle(currentHitbox.GetHandleYScale() + targetComponents.GameObject.transform.position,
                                                 Quaternion.identity,
                                                 0.05f,
                                                 Vector3.one,
                                                 Handles.DotCap);
        ScaleHandleYPos -= targetComponents.GameObject.transform.position;

        currentHitbox.Boundaries = new Rect(currentHitbox.Boundaries.x, currentHitbox.Boundaries.y,
                                            ScaleHandleXPos.x - currentHitbox.Boundaries.x,
                                            ScaleHandleYPos.y - currentHitbox.Boundaries.y);
        return(currentHitbox);
    }
示例#8
0
    private Hitbox DrawScale(Hitbox currentHitbox, TargetComponents targetComponents)
    {
        Vector3 ScaleHandleXPos;
        Vector3 ScaleHandleYPos;

        ScaleHandleXPos = Handles.FreeMoveHandle(currentHitbox.GetHandleXScale() + targetComponents.GameObject.transform.position,
                                                 Quaternion.identity,
                                                 0.05f,
                                                 Vector3.one,
                                                 Handles.DotCap);
        ScaleHandleXPos -= targetComponents.GameObject.transform.position;

        ScaleHandleYPos = Handles.FreeMoveHandle(currentHitbox.GetHandleYScale() + targetComponents.GameObject.transform.position,
                                                 Quaternion.identity,
                                                 0.05f,
                                                 Vector3.one,
                                                 Handles.DotCap);
        ScaleHandleYPos -= targetComponents.GameObject.transform.position;

        currentHitbox.Boundaries = new Rect(currentHitbox.Boundaries.x, currentHitbox.Boundaries.y,
                                      ScaleHandleXPos.x - currentHitbox.Boundaries.x,
                                      ScaleHandleYPos.y - currentHitbox.Boundaries.y);
        return currentHitbox;
    }
示例#9
0
 public Hitbox DrawSceneHandle(Hitbox hitbox, TargetComponents targetComponents)
 {
     return hitbox;
 }
示例#10
0
 public Hitbox DrawSceneHandle(Hitbox hitbox, TargetComponents targetComponents)
 {
     return(hitbox);
 }
示例#11
0
    private void OnLostFocus()
    {
        EditorApplication.update -= OnEditorUpdate;

        if (targetComponents.SpriteRenderer != null)
        {
            //TODO check why not working
            targetComponents.SpriteRenderer.sprite = targetComponents.spriteWhenGotFocus;
            targetComponents = null;
            serializedObject.Update();
            serializedObject.ApplyModifiedProperties();
        }
    }
示例#12
0
    void OnEnable()
    {
        EditorApplication.update += OnEditorUpdate;

        if (hitboxBackgroundStyle == null)
        {
            hitboxBackgroundStyle = new GUIStyle();
            hitboxBackgroundStyle.normal.background = MakeTexture(1, 1, new Color(0f, 0f, 0f, 0.2f));
        }
        //When changing scenes the background is deleted
        else if (hitboxBackgroundStyle.normal.background == null)
        {
            hitboxBackgroundStyle.normal.background = MakeTexture(1, 1, new Color(0f, 0f, 0f, 0.2f));
        }

        targetComponents = new TargetComponents(target);
        zeroHitboxClipsFeeder = new ZeroHitBoxClipsFeeder(targetComponents.ZeroHitbox);

        zeroHitboxClipsFeeder.FeedAnimationClips(targetComponents.Animator);

        //TODO maybe get previously set value?
        keyframesIndex = 0;
        animationClipsIndex = 0;
    }