protected virtual void Awake() { this.collider = this.GetComponent <Collider>(); this.rigidbody = this.GetComponent <Rigidbody>(); this.initialDrag = this.rigidbody.drag; this.initialAngularDrag = this.rigidbody.angularDrag; if (this.calculateDensity) { float objectVolume = MathfUtils.CalculateVolume_Mesh(this.GetComponent <MeshFilter>().mesh, this.transform); this.density = this.rigidbody.mass / objectVolume; } }
protected void Awake() { this.collider = FindComponent <Collider>(); this.rigidbody = FindComponent <Rigidbody>(); this.initialDrag = this.rigidbody.drag; this.initialAngularDrag = this.rigidbody.angularDrag; if (this.calculateDensity) { MeshFilter mesh = GetComponent <MeshFilter>(); if (mesh == null) { mesh = GetComponentInChildren <MeshFilter>(); } float objectVolume = MathfUtils.CalculateVolume_Mesh(mesh.mesh, this.transform); this.density = this.rigidbody.mass / objectVolume; } this.voxels = this.CutIntoVoxels(); }