public void Clip(PhotoSnap anchor, string caller, bool instantTransition = false) { Debug.Log("isClipped = true " + caller); _isClipped = true; _anchor = anchor; anchor.EjectOtherAndRegisterMe(this); if (instantTransition) { _transitionTime = _transitionDuration * 0.99f; } else { _transitionTime = 0f; } StartGrabbing(anchor._snappingPoint, true); //ClipEventManager.singleton.ClipEvent(_identity, _anchor._name); }
public void Unclip(string caller) { //ClipEventManager.singleton.UnclipEvent(_identity, _anchor._name); Debug.Log("isClipped = false " + caller); _isClipped = false; _anchor = null; StopGrabbing(); }
public bool StartGrabbing(Transform parent, bool adaptScale = false) { if (!_isGrabbable) { return false; } Vector3 scaleBefore = _tr.lossyScale; this.transform.SetParent(parent, true); Vector3 scaleAfter = _tr.lossyScale; if (_scaleChangeOnClip && adaptScale) { _tr.localScale = new Vector3(_tr.localScale.x / (scaleAfter.x / scaleBefore.x), _tr.localScale.y / (scaleAfter.y / scaleBefore.y), _tr.localScale.z / (scaleAfter.z / scaleBefore.z)); } _rigid.useGravity = true; _rigid.isKinematic = true; _isBeingGrabbed = true; if (_isClipped && _anchor != null) { //ClipEventManager.singleton.UnclipEvent(_identity, _anchor._name); } if (_isClipped && !adaptScale) { _anchor.UnregisterMe(this); Debug.Log("GrabbableObject.StartGrabbing"); _isClipped = false; _anchor = null; } if (Grabbed != null) { Grabbed.Invoke(); } return true; }