protected override bool Initialize() { if (Material1 == null || Material2 == null) { Debug.LogWarning(name + ": Trying to create contact material with at least one unreferenced ShapeMaterial.", this); return(false); } agx.Material m1 = Material1.GetInitialized <ShapeMaterial>().Native; agx.Material m2 = Material2.GetInitialized <ShapeMaterial>().Native; agx.ContactMaterial old = GetSimulation().getMaterialManager().getContactMaterial(m1, m2); if (old != null) { Debug.LogWarning(name + ": Material manager already contains a contact material with this material pair. Ignoring this contact material.", this); return(false); } m_contactMaterial = GetSimulation().getMaterialManager().getOrCreateContactMaterial(m1, m2); if (FrictionModel != null) { m_contactMaterial.setFrictionModel(FrictionModel.GetInitialized <FrictionModel>().Native); // When the user changes friction model type (enum = BoxFriction, ScaleBoxFriction etc.) // the friction model object will create a new native instance. We'll receive callbacks // when this happens so we can assign it to our native contact material. FrictionModel.OnNativeInstanceChanged += OnFrictionModelNativeInstanceChanged; } return(true); }