public GameObject MySnapZone; //The snap zone that this snappable object suppose to be snapped to. #endregion #region SnapOrder Methods (Logic) /// <summary> /// The snapFlag is to tell whether or not the object is snapped. /// /// </summary> // Start is called before the first frame update void Start() { snapFlag = SnapOrderFlag.INTERACTABLE; //Inialize the snap flag with interactable; thisCollider = GetComponent <Collider>(); //Get this object's collider SwitchSnapAreasOff(); //Switch off all snap areas AssemblyBase = snapOrderObjects[0]; //Get the first snappable object in the list to be tha base. AssemblyBase.SwitchSnapAreasOn(); //Switch the snappable objects' base object's snap areas on. }
/// <summary> /// OnSnappingThis() /// This method will be called at the method SnapObject() in the VRTK_SnapDrobZone.cs /// This piece of logic is added by US at Bright vision in the VRTK script; /// On Snapping this snappable object a bunch of actions should happen excluding /// the base snappable object because it has different behavior. /// /// Method functionality: /// (1) check if it is not the base snappable object because tha base has differnet behavior. /// (2) Mark the flag of the snappable object to be Snapped. /// (3) Check if the previous snappable object in the list is not the base snappable object. /// (4) if the previous snappable object in the list is not the base then disable its collider in order to be still. /// (5) Turn off the collider of the snap zone of this snappable object in order to avoid colliders conflects. /// (6) Switch the snap zone(s) of the next snappable object(s). /// /// Future Version of this method functionality should include: /// (1) There must be an associate class to declare a level of snap order which the level criteria should be as following: /// - More than on object can be in the same snap order level. /// - The whole level has to be completed in order to move on tot he next snap order level. /// - After completing the snap order level the colliders of all the finished level objects must be disabled. /// (2) There is something important I forgut but it may be included in the previous point or not. /// </summary> public void OnSnappingThis() { //check if it is not the base snappable object if (this != AssemblyBase) { //Mark the flag of the snappable object to be SNAPPED snapFlag = SnapOrderFlag.SNAPPED; int thisSnapOrderIndex = snapOrderObjects.IndexOf(this); //Check if the previous snappable object in the list is not the base snappable object if (snapOrderObjects[thisSnapOrderIndex - 1] != AssemblyBase) { //if the previous snappable object in the list is not the base then disable its collider in order to be still snapOrderObjects[thisSnapOrderIndex - 1].thisCollider.enabled = false; } //Turn off the collider of the snap zone of this snappable object in order to avoid colliders conflects. this.MySnapZone.GetComponent <Collider>().enabled = false; //Switch on the snap zone(s) of the next snappable object(s) SwitchSnapAreasOn(); } }
/// <summary> /// This method is totally the opposite behavior of the OnSnappingThis(). /// </summary> public void OnUnSnappingThis() { //check if it is not the base snappable object if (this != AssemblyBase) { //Mark the flag of the snappable object to be INTERACTABLE snapFlag = SnapOrderFlag.INTERACTABLE; int thisSnapOrderIndex = snapOrderObjects.IndexOf(this); //Check if the previous snappable object in the list is not the base snappable object if (snapOrderObjects[thisSnapOrderIndex - 1] != AssemblyBase) { //if the previous snappable object in the list is not the base then enable its collider in order to be still snapOrderObjects[thisSnapOrderIndex - 1].thisCollider.enabled = true; } //Turn on the collider of the snap zone of this snappable object in order to be able to snap this snappable object again. this.MySnapZone.GetComponent <Collider>().enabled = true; //Switch off the snap zone(s) of the next snappable object(s) SwitchSnapAreasOff(); } }