private void DoPivotGUI() { EditorGUI.BeginChangeCheck(); int alignment = s_Setting.spriteAlignment; alignment = EditorGUILayout.Popup(s_Styles.pivotLabel, alignment, s_Styles.spriteAlignmentOptions); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(s_Setting, "Change Alignment"); s_Setting.spriteAlignment = alignment; s_Setting.pivot = SpriteEditorUtility.GetPivotValue((SpriteAlignment)alignment, s_Setting.pivot); } Vector2 pivot = s_Setting.pivot; EditorGUI.BeginChangeCheck(); using (new EditorGUI.DisabledScope(alignment != (int)SpriteAlignment.Custom)) { pivot = EditorGUILayout.Vector2Field(s_Styles.customPivotLabel, pivot); } if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(s_Setting, "Change custom pivot"); s_Setting.pivot = pivot; } }
public void SetSpritePivotAndAlignment(Vector2 pivot, SpriteAlignment alignment) { undoSystem.RegisterCompleteObjectUndo(m_RectsCache, "Change Sprite Pivot"); spriteEditor.SetDataModified(); selected.alignment = alignment; selected.pivot = SpriteEditorUtility.GetPivotValue(alignment, pivot); }
internal SpriteDataExt(SerializedProperty sp) { rect = sp.FindPropertyRelative("m_Rect").rectValue; border = sp.FindPropertyRelative("m_Border").vector4Value; name = sp.FindPropertyRelative("m_Name").stringValue; alignment = (SpriteAlignment)sp.FindPropertyRelative("m_Alignment").intValue; pivot = SpriteEditorUtility.GetPivotValue(alignment, sp.FindPropertyRelative("m_Pivot").vector2Value); tessellationDetail = sp.FindPropertyRelative("m_TessellationDetail").floatValue; spriteID = new GUID(sp.FindPropertyRelative("m_SpriteID").stringValue); internalID = sp.FindPropertyRelative("m_InternalID").longValue; }
internal SpriteDataExt(SerializedObject so) { var ti = so.targetObject as TextureImporter; name = Path.GetFileNameWithoutExtension(ti.assetPath); alignment = (SpriteAlignment)so.FindProperty("m_Alignment").intValue; border = ti.spriteBorder; pivot = SpriteEditorUtility.GetPivotValue(alignment, ti.spritePivot); tessellationDetail = so.FindProperty("m_SpriteTessellationDetail").floatValue; int width = 0, height = 0; ti.GetWidthAndHeight(ref width, ref height); rect = new Rect(0, 0, width, height); var guidSP = so.FindProperty("m_SpriteSheet.m_SpriteID"); spriteID = new GUID(guidSP.stringValue); internalID = so.FindProperty("m_SpriteSheet.m_InternalID").longValue; }