public void RemoveAnchor() { if (_anchor != null) { _anchor.RemoveAnchor(); _anchor = null; } }
public void RemoveAnchor() { if (Anchor != null) { Anchor.RemoveAnchor(); Anchor = null; Anchored = false; } }
public virtual PartialViewResult Anchor(AnchorComponent component) { if (component == null) { throw new ArgumentNullException("component"); } return(PartialView(component)); }
public void AnchorTo(IAnchorable target, PositionType style, int offsetX = 0, int offsetY = 0, AnchorType anchorType = AnchorType.Bounds) { if (target != (IAnchorable)this) { RemoveAnchor(); _anchor = new AnchorComponent(target, this, anchorType, style, new MonoGame.Extended.Size2(offsetX, offsetY)); return; } Console.WriteLine("WARNING: Attempted to anchor this object to itself."); }
public void AnchorTo(IAnchorable target, AnchorAlignment alignment, PositionOffset offset) { if (target.GetHashCode() != GetHashCode()) { RemoveAnchor(); Anchor = new AnchorComponent(target, this, alignment, offset); Position = Anchor.AnchoredPosition; Anchored = true; return; } throw new NotSupportedException("Cannot anchor an object to itself."); }
void OnSceneGUI() { AnchorComponent compontent = target as AnchorComponent; Handles.color = compontent.color; //绘制实心正方体 //Handles.CubeCap(compontent.GetInstanceID(), compontent.transform.position, compontent.transform.rotation, 1.0f); //绘制线框正方体 DrawWireframeBox(compontent.transform, compontent.isUserLossyScale, compontent.isUserHandlesSize); }
public void AttachToNearestAnchor(IAnchorUser _anchorUser) { AnchorComponent nearestAnchor = FindNearestAnchorComponent(_anchorUser.GetRigidbody2D().transform.position); if (nearestAnchor != null) { nearestAnchor.AttachUser(_anchorUser); } else { Debug.LogWarning("No anchors found to attach the body"); } }
public void Detach(IAnchorUser _user) { AnchorComponent attachedAnchor = null; foreach (AnchorComponent _anchor in m_anchorComponentList) { if (_anchor.IsAttachedToUser(_user)) { attachedAnchor = _anchor; } } if (attachedAnchor != null) { attachedAnchor.DetachUser(); } }
private AnchorComponent FindNearestAnchorComponent(Vector2 _position) { float shortestDistance = int.MaxValue; AnchorComponent nearestAnchor = null; foreach (AnchorComponent _component in m_anchorComponentList) { float distance = (_position - (Vector2)_component.transform.position).sqrMagnitude; if (distance < shortestDistance) { shortestDistance = distance; nearestAnchor = _component; } } return(nearestAnchor); }
public AnchorComponent FindNearestAnchorComponent(Vector2 _position) { float shortestDistance = Mathf.Infinity; AnchorComponent nearestAnchor = null; foreach (AnchorComponent _component in m_anchorComponentList) { float distance = (_position - (Vector2)_component.transform.position).sqrMagnitude; if (distance < shortestDistance) { foreach (var anchor in m_anchorComponentList) { anchor.UnmarkAnchor(); } shortestDistance = distance; nearestAnchor = _component; nearestAnchor.MarkAnchor(); } } return(nearestAnchor); }
public void RegisterAnchor(AnchorComponent _component) { m_anchorComponentList.Add(_component); }
public void UnregisterAnchor(AnchorComponent _component) { m_anchorComponentList.Remove(_component); }
public void AnchorTo(IAnchorable target, PositionType style, int offsetX = 0, int offsetY = 0, AnchorType anchorType = AnchorType.Bounds) { RemoveAnchor(); _anchor = new AnchorComponent(target, this, anchorType, style, new MonoGame.Extended.Size2(offsetX, offsetY)); }