示例#1
0
 /// <summary>
 /// Try to pick up a pickable object. Return true if successful. It may fail because
 /// the pickable object is being held by a picker whose <see cref="AllowSwitchingPicker"/>
 /// is false.
 /// </summary>
 /// <param name="pickable">The pickable object.</param>
 /// <returns>True if successful.</returns>
 protected bool AttachPickable(IPickable pickable)
 {
     if (pickable.IsPicked)
     {
         IPicker otherPicker = pickable.Picker;
         if (otherPicker == this)
         {
             Debug.LogError("Picking the same object.");
             return(false);
         }
         if (!otherPicker.AllowSwitchingPicker)
         {
             return(false);
         }
         else
         {
             // Switch picker
             otherPicker.SwitchPickerRelease();
         }
     }
     PickedObj = pickable;
     IsHolding = true;
     pickable.OnPickedInit(this);
     return(true);
 }