1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using UnityEngine;
- namespace UnityEditor.U2D.Animation
- {
- internal class SkeletonToolWrapper : BaseTool
- {
- private SkeletonTool m_SkeletonTool;
- private SkeletonMode m_Mode;
- public SkeletonTool skeletonTool
- {
- get { return m_SkeletonTool; }
- set { m_SkeletonTool = value; }
- }
- public SkeletonMode mode
- {
- get { return m_Mode; }
- set { m_Mode = value; }
- }
- public bool editBindPose { get; set; }
- public override int defaultControlID
- {
- get
- {
- Debug.Assert(skeletonTool != null);
- return skeletonTool.defaultControlID;
- }
- }
- protected override void OnActivate()
- {
- Debug.Assert(skeletonTool != null);
- skeletonTool.enableBoneInspector = true;
- skeletonTool.Activate();
- }
- protected override void OnDeactivate()
- {
- skeletonTool.enableBoneInspector = false;
- skeletonTool.Deactivate();
- }
- private SkeletonMode OverrideMode()
- {
- var modeOverride = mode;
- //Disable SkeletonManipulation if character exists and we are in SpriteSheet mode
- if (skinningCache.mode == SkinningMode.SpriteSheet && skinningCache.hasCharacter && editBindPose)
- modeOverride = SkeletonMode.Selection;
- return modeOverride;
- }
- protected override void OnGUI()
- {
- Debug.Assert(skeletonTool != null);
- skeletonTool.mode = OverrideMode();
- skeletonTool.editBindPose = editBindPose;
- skeletonTool.DoGUI();
- }
- }
- }
|