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; }
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(); } }
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); }
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); }
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; }
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; }
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); }
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; }
public Hitbox DrawSceneHandle(Hitbox hitbox, TargetComponents targetComponents) { return hitbox; }
public Hitbox DrawSceneHandle(Hitbox hitbox, TargetComponents targetComponents) { return(hitbox); }