public PhysicMaterialReplacer(Transform anchor, InteractionMaterial material) { _colliders = anchor.GetComponentsInChildren<Collider>(true); _originalMaterials = _colliders.Select(c => c.sharedMaterial).ToArray(); switch (material.PhysicMaterialMode) { case InteractionMaterial.PhysicMaterialModeEnum.NoAction: _replacementMaterials = null; break; case InteractionMaterial.PhysicMaterialModeEnum.DuplicateExisting: _replacementMaterials = _originalMaterials.Select(m => { PhysicMaterial newMat; if (m == null) { newMat = new PhysicMaterial(); newMat.name = "Grasping Material"; } else { newMat = Object.Instantiate(m); newMat.name = m.name + " (Grasping Instance)"; } newMat.bounciness = 0; return newMat; }).ToArray(); break; case InteractionMaterial.PhysicMaterialModeEnum.Replace: _replacementMaterials = _originalMaterials.Select(m => material.ReplacementPhysicMaterial).ToArray(); break; } }
private void CheckMaterial() { if (_material == null) { if (_manager == null) { return; } else { Debug.LogWarning("No InteractionMaterial specified; will use the default InteractionMaterial as specified by the InteractionManager."); _material = _manager.DefaultInteractionMaterial; } } }