/// <summary> /// Set the position active or inactive regarding their content. /// If true, activate only the free zones, which are not the one where we just cut object. /// </summary> /// <param name="active"></param> private void SetPositionsActive(bool active) { for (int i = 0; i < availablePositions.Count; i++) { PasteContainer pos = availablePositions[i]; pos.gameObject.SetActive(active && (pos.IsFree || (selectedObject != null && pos.containedGameObject == selectedObject.gameObject))); } }
/// <summary> /// Called when used focus on a zone, to paste the object he just cut. /// </summary> /// <param name="zone">The focused zone</param> public void OnTriggerPosition(PasteContainer zone) { // If we did not cut an object, leave the function. if (selectedObject == null) { return; } // Remove from old position. for (int i = 0; i < availablePositions.Count; i++) { if (availablePositions[i].containedGameObject == selectedObject.gameObject) { availablePositions[i].OnChangeContent(null); break; } } // Link the object to the chosen zone. zone.OnChangeContent(selectedObject.gameObject); // Disactivate all the zones. SetPositionsActive(false); // Make the pasted object reappear smoothly by scaling it up. StartCoroutine(SmoothScale(true, selectedObject.transform)); // Active all the objects neurotags foreach (var c in interactibleObjects) { NeuroTag tag = c.GetComponent <NeuroTag>(); if (tag != selectedObject) { tag.enabled = true; } } // Active the NeuroTag on the pasted object after a few second. // If it is reactivated directly, it can happen than the user focus on it and trigger it too quickly. StartCoroutine(DelayedActivation(selectedObject)); selectedObject = null; }