private void OnEndRotate(BaseHandle rotationHandle) { IMeshEditor meshEditor = GetEditor(); if (meshEditor != null) { rotationHandle.EnableUndo = true; Quaternion initialRotation = m_initialRotation; Quaternion endRotation = m_pivot.rotation; meshEditor.EndRotate(); Quaternion newStartRotation = GetPivotRotation(meshEditor); m_pivot.rotation = newStartRotation; if (UVEditingMode) { m_rte.Undo.EndRecordValue(UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.rotation)); } else { m_rte.Undo.CreateRecord(record => { meshEditor.BeginRotate(initialRotation); meshEditor.Rotate(endRotation); meshEditor.EndRotate(); m_pivot.transform.rotation = newStartRotation; return(true); }, record => { meshEditor.BeginRotate(endRotation); meshEditor.Rotate(initialRotation); meshEditor.EndRotate(); m_pivot.transform.rotation = initialRotation; return(true); }); } } }
private void OnEndScale(BaseHandle scaleHandle) { IMeshEditor meshEditor = GetEditor(); if (meshEditor != null) { scaleHandle.EnableUndo = true; meshEditor.EndScale(); Vector3 newScale = m_pivot.localScale; Quaternion rotation = m_pivot.rotation; m_pivot.localScale = Vector3.one; if (UVEditingMode) { m_rte.Undo.EndRecordValue(UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.scale)); } else { m_rte.Undo.CreateRecord(record => { meshEditor.BeginScale(); meshEditor.Scale(newScale, rotation); meshEditor.EndScale(); return(true); }, record => { meshEditor.BeginScale(); meshEditor.Scale(new Vector3(1.0f / newScale.x, 1.0f / newScale.y, 1.0f / newScale.z), rotation); meshEditor.EndRotate(); return(true); }); } } }