void Update() { if (mIsDragging) { Vector2 aPosition = uThumb.GetManager().ScreenToGui(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); aPosition = new Vector2(aPosition.x, 0 - aPosition.y); // TODO: these numbers are hardcoded - copied from the unity gui - figure out how to get this programatically Vector2 relativePosition = new Vector2(aPosition.x - 179, aPosition.y + 521); if (relativePosition.x < 0) { relativePosition = new Vector2(0, relativePosition.y); } if (relativePosition.x > 420) { relativePosition = new Vector2(420, relativePosition.y); } mRecordingPlayer.Jump(relativePosition.x / (420 / 30)); if (!Input.GetMouseButton(0)) { mIsDragging = false; mRecordingPlayer.Continue(); } } if (mRecordingPlayer != null) { uThumb.Position = new Vector2((float)mRecordingPlayer.uTime * (420 / 30), 0); } }
private IEnumerator resetZoom() { var controlSize = control.Size; var screenSize = control.GetManager().GetScreenSize(); var animatedSize = new dfAnimatedVector2(control.Size, controlSize, 0.2f); if (controlSize.x >= screenSize.x - 10 || controlSize.y >= screenSize.y - 10) { animatedSize.EndValue = fitImage(screenSize.x * 0.75f, screenSize.y * 0.75f, control.Width, control.Height); } else { animatedSize.EndValue = fitImage(screenSize.x, screenSize.y, control.Width, control.Height); } var endPosition = new Vector3(screenSize.x - animatedSize.EndValue.x, screenSize.y - animatedSize.EndValue.y, 0) * 0.5f; var animatedPosition = new dfAnimatedVector3(control.RelativePosition, endPosition, animatedSize.Length); var animatedRotation = new dfAnimatedQuaternion(control.transform.rotation, Quaternion.identity, animatedSize.Length); while (!animatedSize.IsDone) { control.Size = animatedSize; control.RelativePosition = animatedPosition; control.transform.rotation = animatedRotation; yield return(null); } }
void OnMouseDown() { GameObject g = (GameObject)Instantiate(mRecordingPropPrefab, Vector3.zero, Quaternion.identity); g.transform.parent = mScreen.transform; Vector2 mousePosition = uImage.GetManager().ScreenToGui(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); dfTextureSprite sprite = (dfTextureSprite)g.GetComponent(typeof(dfTextureSprite)); // TODO: these numbers are hardcoded - copied from the unity gui - figure out how to get this programatically Vector2 top_left = new Vector2(mousePosition.x - 183, (0 - mousePosition.y) + 123); sprite.Position = new Vector2(top_left.x - (sprite.Size.x / 2), top_left.y + (sprite.Size.y / 2)); sprite.Texture = (Texture2D)Resources.Load("Props/" + uPurchasedProp.uProp.uID); sprite.Size = new Vector2(sprite.Texture.width, sprite.Texture.height); RecordingProp r = (RecordingProp)g.GetComponent(typeof(RecordingProp)); r.uPurchasedProp = uPurchasedProp; MovingArea p = g.GetComponentInChildren <MovingArea>(); p.OnMouseDown(); mProps.Remove(uPurchasedProp); }
public IEnumerator OnDoubleTapGesture() { if (DisplayImage == null) { Debug.LogWarning("The DisplayImage property is not configured, cannot select the image"); yield break; } var photo = ((GameObject)Instantiate(DisplayImage.gameObject)).GetComponent <dfTextureSprite>(); myImage.GetManager().AddControl(photo); photo.Texture = myImage.Texture; photo.Size = myImage.Size; photo.RelativePosition = myImage.GetAbsolutePosition(); photo.transform.rotation = Quaternion.identity; photo.BringToFront(); photo.Opacity = 1f; photo.IsVisible = true; var screenSize = myImage.GetManager().GetScreenSize(); var fullSize = new Vector2(photo.Texture.width, photo.Texture.height); var displaySize = fitImage(screenSize.x * 0.75f, screenSize.y * 0.75f, fullSize.x, fullSize.y); var displayPosition = new Vector3((screenSize.x - displaySize.x) * 0.5f, (screenSize.y - displaySize.y) * 0.5f); var animatedPosition = new dfAnimatedVector3(myImage.GetAbsolutePosition(), displayPosition, 0.2f); var animatedSize = new dfAnimatedVector2(myImage.Size, displaySize, 0.2f); while (!animatedPosition.IsDone || !animatedSize.IsDone) { photo.Size = animatedSize; photo.RelativePosition = animatedPosition; yield return(null); } }
void OnMouseDown() { GameObject g = (GameObject)Instantiate(mDialoguePrefab, Vector3.zero, Quaternion.identity); g.transform.parent = mScreen.transform; Vector2 mousePosition = uImage.GetManager().ScreenToGui(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); dfSlicedSprite sprite = g.GetComponent <dfSlicedSprite>(); // TODO: these numbers are hardcoded - copied from the unity gui - figure out how to get this programatically Vector2 top_left = new Vector2(mousePosition.x - 183, (0 - mousePosition.y) + 123); sprite.Position = new Vector2(top_left.x - (sprite.Size.x / 2), top_left.y + (sprite.Size.y / 2)); sprite.SpriteName = uBackgroundSpriteName; sprite.Size = new Vector2(300, 300); MovingArea p = g.GetComponentInChildren <MovingArea>(); p.OnMouseDown(); }
void OnMouseDown() { mOriginalPosition = mSprite.GetManager().ScreenToGui(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); mOriginalRotation = mSprite.transform.eulerAngles.z; mIsDragging = true; }