Example #1
0
 /// <summary>
 /// 强制释放抓取的物体
 /// </summary>
 protected virtual void ForceReleaseGrab()
 {
     if (grabbedObjectScript)
     {
         GameObject grabbingObject = grabbedObjectScript.GetGrabbingObject();
         if (grabbingObject != null)
         {
             Grab_Interact grabbingObjectScript = grabbingObject.GetComponentInChildren <Grab_Interact>();
             if (grabbingObjectScript != null)
             {
                 grabbingObjectScript.ForceRelease();
             }
         }
     }
 }
Example #2
0
    /// <summary>
    /// 停止抓取物体
    /// </summary>
    protected virtual void StopGrabbingInteractions()
    {
        GameObject grabbingObject = GetGrabbingObject();

        if (grabbingObject != null && (grabbingObject.activeInHierarchy || forceDisabled))
        {
            Grab_Interact grabbingObjectScript = grabbingObject.GetComponentInChildren <Grab_Interact>();
            if (grabbingObjectScript != null && grabbingObjectScript != null)
            {
                grabbingObjectScript.ForceStopTouching();
                grabbingObjectScript.ForceRelease();
                forcedDropped = true;
            }
        }
    }