public static PivotTransform SFB_Setup(this PivotTransform pt, bool always = false) { if (pt.Pivot_Transform != null) { if (pt.ReImport) { ReImport(pt.Pivot_Transform.gameObject); pt.ReImport = false; } if (pt.ChangePivot) { pt = pt.SFB_CalcMinMaxOffset(); pt = pt.SFB_PivotUpdate(); pt.ChangePivot = false; } if (always) { pt = pt.SFB_CalcMinMaxOffset(); pt = pt.SFB_PivotUpdate(); } pt = pt.SFB_PivotReset(); } return(pt); }
public static PivotTransform SFB_PivotReset(this PivotTransform pt) { if (pt.Pivot_Transform_INT != pt.Pivot_Transform) { pt.mesh = pt.Pivot_Transform.GetComponent <MeshFilter>().sharedMesh; pt.OriginalVertices = pt.mesh.vertices; pt.vertices = pt.mesh.vertices; pt.normals = pt.mesh.normals; pt.tangents = pt.mesh.tangents; pt.OriginalRotation = pt.Pivot_Transform.localRotation; Vector3 OriginaPosition = pt.Pivot_Transform.position; pt.Pivot_Transform.position = Vector3.zero; //center pivot to model pt.PivotOffset = pt.Pivot_Transform.position - pt.Pivot_Transform.GetComponent <Renderer>().bounds.center; pt.SFB_PivotUpdate(); pt.Pivot_Transform.position = OriginaPosition; pt.OriginalVertices = pt.mesh.vertices; pt.Pivot_Transform_INT = pt.Pivot_Transform; } return(pt); }