예제 #1
0
        /// <summary>
        /// The ToggleSnapDropZone method is used to set the state of whether the interactable object is in a Snap Drop Zone or not.
        /// </summary>
        /// <param name="snapDropZone">The Snap Drop Zone object that is being interacted with.</param>
        /// <param name="state">The state of whether the interactable object is fixed in or removed from the Snap Drop Zone. True denotes the interactable object is fixed to the Snap Drop Zone and false denotes it has been removed from the Snap Drop Zone.</param>
        /// <param name="newLocalScale">A Vector3 containing the new scale value of the interactable object when it has been toggled.</param>
        public void ToggleSnapDropZone(VRTK_SnapDropZone snapDropZone, bool state, Vector3 newLocalScale)
        {
            if (state && inSnapDropZone)
            {
                return;
            }

            inSnapDropZone = state;
            if (state)
            {
                if (!newLocalScale.Equals(Vector3.zero))
                {
                    previousLocalScale   = transform.localScale;
                    transform.localScale = Vector3.Scale(previousLocalScale, newLocalScale);
                }
                SetDropSnapType(snapDropZone);
            }
            else
            {
                ResetDropSnapType();
                if (!previousLocalScale.Equals(Vector3.zero))
                {
                    transform.localScale = previousLocalScale;
                }
            }
        }
예제 #2
0
        private void ResetDropSnapType()
        {
            switch (storedSnapDropZone.snapType)
            {
            case VRTK_SnapDropZone.SnapTypes.Use_Kinematic:
            case VRTK_SnapDropZone.SnapTypes.Use_Parenting:
                LoadPreviousState();
                break;

            case VRTK_SnapDropZone.SnapTypes.Use_Joint:
                var snapDropZoneJoint = storedSnapDropZone.GetComponent <Joint>();
                if (snapDropZoneJoint)
                {
                    snapDropZoneJoint.connectedBody = null;
                }
                break;
            }

            if (!previousLocalScale.Equals(Vector3.zero))
            {
                transform.localScale = previousLocalScale;
            }

            storedSnapDropZone.OnObjectUnsnappedFromDropZone(storedSnapDropZone.SetSnapDropZoneEvent(gameObject));
            storedSnapDropZone = null;
        }
예제 #3
0
 private void Awake()
 {
     MarkerResetButton = GetComponentInChildren <VRTK_PhysicsPusher>();
     Marker            = GameObject.Find("Marker");
     ResetLocation     = gameObject.transform.Find("ResetLocation").transform;
     reseted           = false;
     storedSnapZone    = null;
 }
예제 #4
0
 void Start()
 {
     boxSnap           = GetComponent <VRTK_SnapDropZone>();
     notSnapped        = true;
     previouslySnapped = null;
     boxCounter        = 0;
     invisible         = null;
     BoxStackingSound  = GetComponent <AudioSource>();
 }
예제 #5
0
        private void SetSnapDropZoneJoint(VRTK_SnapDropZone snapDropZone, Rigidbody snapTo)
        {
            var snapDropZoneJoint = snapDropZone.GetComponent <Joint>();

            if (snapDropZoneJoint == null)
            {
                Debug.LogError("No Joint Component was found on the SnapDropZone GameObject yet the Snap Type is set to `Use Joint`. Please manually add a joint to the SnapDropZone GameObject.");
                return;
            }
            snapDropZoneJoint.connectedBody = snapTo;
        }
예제 #6
0
 /// <summary>
 /// The ToggleSnapDropZone method is used to set the state of whether the interactable object is in a Snap Drop Zone or not.
 /// </summary>
 /// <param name="snapDropZone">The Snap Drop Zone object that is being interacted with.</param>
 /// <param name="state">The state of whether the interactable object is fixed in or removed from the Snap Drop Zone. True denotes the interactable object is fixed to the Snap Drop Zone and false denotes it has been removed from the Snap Drop Zone.</param>
 public virtual void ToggleSnapDropZone(VRTK_SnapDropZone snapDropZone, bool state)
 {
     snappedInSnapDropZone = state;
     if (state)
     {
         storedSnapDropZone = snapDropZone;
     }
     else
     {
         ResetDropSnapType();
     }
 }
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            theScript = go.GetComponent <VRTK.VRTK_SnapDropZone>();

            if (!everyFrame.Value)
            {
                MakeItSo();
                Finish();
            }
        }
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            snapzone = go.GetComponent <VRTK.VRTK_SnapDropZone>();

            doSnappy();

            if (!everyFrame.Value)
            {
                Finish();
            }
        }
예제 #9
0
 /// <summary>
 /// The ToggleSnapDropZone method is used to set the state of whether the interactable object is in a Snap Drop Zone or not.
 /// </summary>
 /// <param name="snapDropZone">The Snap Drop Zone object that is being interacted with.</param>
 /// <param name="state">The state of whether the interactable object is fixed in or removed from the Snap Drop Zone. True denotes the interactable object is fixed to the Snap Drop Zone and false denotes it has been removed from the Snap Drop Zone.</param>
 public virtual void ToggleSnapDropZone(VRTK_SnapDropZone snapDropZone, bool state)
 {
     snappedInSnapDropZone = state;
     if (state)
     {
         storedSnapDropZone = snapDropZone;
         OnInteractableObjectSnappedToDropZone(SetInteractableObjectEvent(snapDropZone.gameObject));
     }
     else
     {
         ResetDropSnapType();
         OnInteractableObjectUnsnappedFromDropZone(SetInteractableObjectEvent(snapDropZone.gameObject));
     }
 }
예제 #10
0
 void Update()
 {
     if (MarkerResetButton.AtMaxLimit() && !reseted)
     {
         reseted = true;
         Marker.transform.position = ResetLocation.transform.position;
         storedSnapZone            = Marker.GetComponent <VRTK_InteractableObject>().GetStoredSnapDropZone();
         if (storedSnapZone != null)
         {
             storedSnapZone.ForceUnsnap();
         }
         Marker.GetComponent <Rigidbody>().isKinematic = true;
         Game_Manager.instance.beingUnSnapped          = true;
         StartCoroutine("WaitForReset");
     }
 }
예제 #11
0
        private void ResetDropSnapType()
        {
            switch (storedSnapDropZone.snapType)
            {
            case VRTK_SnapDropZone.SnapTypes.Use_Kinematic:
            case VRTK_SnapDropZone.SnapTypes.Use_Parenting:
                LoadPreviousState();
                break;

            case VRTK_SnapDropZone.SnapTypes.Use_Joint:
                SetSnapDropZoneJoint(storedSnapDropZone, null);
                break;
            }

            storedSnapDropZone.OnObjectUnsnappedFromDropZone(storedSnapDropZone.SetSnapDropZoneEvent(gameObject));
            storedSnapDropZone = null;
        }
 /// <summary>
 /// The SetSnapDropZoneHover method sets whether the interactable object is currently being hovered over a valid Snap Drop Zone.
 /// </summary>
 /// <param name="snapDropZone">The Snap Drop Zone object that is being interacted with.</param>
 /// <param name="state">The state of whether the object is being hovered or not.</param>
 public virtual void SetSnapDropZoneHover(VRTK_SnapDropZone snapDropZone, bool state)
 {
     if (state)
     {
         if (!hoveredSnapObjects.Contains(snapDropZone.gameObject))
         {
             hoveredSnapObjects.Add(snapDropZone.gameObject);
             OnInteractableObjectEnteredSnapDropZone(SetInteractableObjectEvent(snapDropZone.gameObject));
         }
     }
     else
     {
         if (hoveredSnapObjects.Contains(snapDropZone.gameObject))
         {
             hoveredSnapObjects.Remove(snapDropZone.gameObject);
             OnInteractableObjectExitedSnapDropZone(SetInteractableObjectEvent(snapDropZone.gameObject));
         }
     }
     hoveredOverSnapDropZone = hoveredSnapObjects.Count > 0;
 }
예제 #13
0
    //TODO Should probably extend "VRTK_Policy List" insted?
    private void EnteringSnap(object arg0, SnapDropZoneEventArgs arg1)
    {
        Debug.Log(DateTime.Now.ToString());
        var snapObj = arg1.snappedObject;

        VRTK.VRTK_SnapDropZone snapZone = (VRTK_SnapDropZone)arg0;
        // Debug.Log(cube.name);
        Debug.Log("Checking if in correct order for: snapObj = " + snapObj.name + ", snapZone = " + snapZone.gameObject.name + ", --- currentCube = " + currentCube);

        if (cubes[currentCube] == snapObj && dropZones[currentCube] == snapZone.gameObject)
        {
            Debug.Log("In correct order!");
        }
        else
        {
            snapZone.highlightColor      = Color.red;
            snapZone.validHighlightColor = Color.red;
            snapZone.enableSnapping      = false;
            Debug.Log("Not in correct order!");
        }
        Debug.Log("");
    }
예제 #14
0
        private void SetDropSnapType(VRTK_SnapDropZone snapDropZone)
        {
            storedSnapDropZone = snapDropZone;

            switch (storedSnapDropZone.snapType)
            {
            case VRTK_SnapDropZone.SnapTypes.Use_Kinematic:
                SaveCurrentState();
                ToggleKinematic(true);
                break;

            case VRTK_SnapDropZone.SnapTypes.Use_Parenting:
                SaveCurrentState();
                ToggleKinematic(true);
                transform.SetParent(storedSnapDropZone.transform);
                break;

            case VRTK_SnapDropZone.SnapTypes.Use_Joint:
                SetSnapDropZoneJoint(storedSnapDropZone, rb);
                break;
            }
            snapDropZone.OnObjectSnappedToDropZone(snapDropZone.SetSnapDropZoneEvent(gameObject));
        }