private void InitPositioning(Vector2 position, bool flyUp) { this.transform.position = position.ToVector3(this.transform.position.z); initialPosition = this.transform.position; if (flyUp) { RectTransform bubbleTransform = GetComponent<RectTransform>(); Rect canvasRect = canvas.GetComponent<RectTransform>().rect; this.targetPosition = canvas.transform.TransformPoint(new Vector3(Random.Range(-180, 180), canvasRect.height / 2 - 140, bubbleTransform.localPosition.z)); } else { this.targetPosition = position.ToVector3(transform.position.z); } }
public static void Translate(this Rigidbody2D rigidbody, Vector2 translation, Axes axes = Axes.XY) { rigidbody.SetPosition(rigidbody.transform.position + translation.ToVector3(), axes); }
public int AddPoint(Vector2 point, int insertPoint) { if(insertPoint < 0 || insertPoint > points.Count-1) points.Add(new PolydrawPoint2(transform.InverseTransformPoint(point.ToVector3(drawSettings.axis, drawSettings.zPosition)).ToVector2(drawSettings.axis))); else points.Insert(insertPoint, new PolydrawPoint2(transform.InverseTransformPoint(point.ToVector3(drawSettings.axis, drawSettings.zPosition)).ToVector2(drawSettings.axis))); #if UNITY_EDITOR EditorUtility.SetDirty(this); #endif return (insertPoint < 0 || insertPoint > points.Count-1) ? points.Count-1 : insertPoint; }
public void SetPoint(int index, Vector2 point) { if(index > -1 && index < points.Count) { PolydrawPoint2 currentPoint = points[index]; PolydrawPoint2 newPoint = new PolydrawPoint2(transform.InverseTransformPoint(point.ToVector3(drawSettings.axis, drawSettings.zPosition)).ToVector2(drawSettings.axis)); newPoint.borderIgnored = currentPoint.borderIgnored; points[index] = newPoint; } #if UNITY_EDITOR EditorUtility.SetDirty(this); #endif }
public void Show(Vector2 position, float zPosition) { this.transform.localPosition = position.ToVector3(zPosition); startTime = Time.time; SetAlpha(0); this.gameObject.SetActive(true); }