예제 #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
파일: Circle.cs 프로젝트: tvalle/ZeroHitbox
 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;
    }