Unity3D Custom Sprite Pivot Editor in SceneView
Unity3D, Sprite, Sprite Pivot, Custom Editor, Pivot Edit, SceneView, 피벗, 피봇, 스프라이트, 설정, 씬뷰, 커스텀 에디터
스프라이트를 이용한 캐릭터 작업시, 너무 번거로운 피벗세팅 때문에 만들게 되었습니다. 관련 패키지를 첨부합니다.
* 주요기능은 다음과 같습니다.
- Edits a pivot in SceneView ( 씬뷰에서 피벗을 설정할 수 있습니다. )
- by presets ( 기본 설정값들로 작업 )
- by dragging gizmo ( 피벗포인트를 드래그 )
- by dragging object ( 해당 오브젝트를 드래그 )
- Gives pixel-perfect pivot option ( 픽셀에 맞춰 피벗을 설정할 수 있습니다. )
- Moves a gameobject along parent's pixel unit
( 부모 스프라이트의 픽셀에 맞춰 오브젝트를 이동할 수 있습니다.)
- Supports Single/Multiple sprite mode.
(싱글/멀티 스프라이트 모드, 모두에 사용가능합니다.)
- Undo is not supported!!! ( Undo기능 없어요. 주의바랍니다. )
* 기능 구현에 사용한 방법은 다음과 같이 간단한 도메인 변환입니다.
- World-Position -> Local-Position -> Pivot
- Pivot -> Local-Position -> World-Position
첨부된 소스코드중,
zUtils.cs::zWorldPositionToPivot, zPivotToWorldPosition
을 참고바랍니다.
* Source codes
Editor/
zCommonEditor.cs : Common editor utilities
zSpriteEditor.cs : Editor-Template for SpriteRenderer
zSpritePivotExt.cs : Custom sprite pivot editor (inherits from zSpriteEditor)
zUtils/
zUtils.cs : Common utilities for sprite pivot
* Desciption
NORMAL-MODE
- Lock Position : on pivot editing, prevents changing of local-position
( 피벗설정시, local-position이 움직이는 것을 방지합니다.)
- Align to Pixel : pivot is snapped to pixel-unit
( 픽셀단위로 피벗을 설정합니다. )
- Presets : default presets, like Center, TopLeft, BottomCenter, and so on
( 기존 피벗 프리셋입니다. )
- Edit : Change mode to EDIT-MODE, ( 피벗설정 모드로 전환합니다. )
In EDIT-MODE, inspector and sceneview are shown as belows:
- Apply : applies editted pivot ( It will change Asset ImportSetting directly )
설정된 피벗을 적용합니다.
- Cancel : cancels (취소)
- Copy : copies current pivot value (Vector2)
(현재 설정된 피벗값을 복사합니다.)
- Paste : pastes copied pivot to current sprite
(복사된 값을 현재 스프라이트에 적용합니다.)
* Press A-Key and move a gameobject : gameobject will move along its parent's pixel-unit.
( A키를 누른상태에서 오브젝트를 이동하면, 부모 스프라이트의 픽셀에 맞출수 있습니다. )
For more information, see the attached video. 첨부된 동영상에 좀더 자세한 설명이 있습니다.