public void DestroyPreviewClamp(RaycastHit hit) { if (previewClamp != null) { Destroy(previewClamp.transform.parent.gameObject); previewClamp = null; } }
public void PreviewClamp(RaycastHit hit) { // If we haven't already created a preview clamp, create one if (previewClamp == null) { Simulation.clampMutex.WaitOne(); previewClamp = BuildClamp(hit); // If we couldn't build a preview clamp, don't try to preview the position hit if (previewClamp == null) { Simulation.clampMutex.ReleaseMutex(); return; } Clamps.Remove(previewClamp); Simulation.clampMutex.ReleaseMutex(); foreach (Collider col in previewClamp.GetComponentsInChildren <Collider>()) { col.enabled = false; } previewClamp.SwitchMaterial(previewClamp.previewMaterial); previewClamp.name = "PreviewClamp"; foreach (GameObject defaultCapHolder in previewClamp.defaultCapHolders) { Destroy(defaultCapHolder); } foreach (GameObject destroyCapHolder in previewClamp.destroyCapHolders) { Destroy(destroyCapHolder); } } // Ensure the clamp is enabled previewClamp.transform.parent.gameObject.SetActive(true); // Set the size and orientation of the preview clamp previewClamp.PlaceClamp(Simulation.GetNearestPoint(hit)); }