summaryrefslogtreecommitdiff
path: root/Assets/ActionTool/Editor/ActionPreviewEditor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/ActionTool/Editor/ActionPreviewEditor.cs')
-rw-r--r--Assets/ActionTool/Editor/ActionPreviewEditor.cs101
1 files changed, 93 insertions, 8 deletions
diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs
index d0934cf9..faad376c 100644
--- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs
+++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs
@@ -15,13 +15,15 @@ namespace ActionTool
Texture m_UITextureEnd;
Texture m_UITexturePrevious;
Texture m_UITextureStart;
+ Texture m_UITextureNewHurtBox;
+ Texture m_UITextureNewHitBox;
GUIStyle m_StyleBold;
const float kToolbarControlMargin = 5;
const float kToolbarHeight = 50;
const float kToolbarControlSize = kToolbarHeight - kToolbarControlMargin * 2;
- const float kTimeLineViewXOffset = 20;
+ const float kTimeLineViewXOffset = 30;
const float kFrameWidth = 10;
const float kFrameHeight = 20;
@@ -39,6 +41,8 @@ namespace ActionTool
m_UITextureEnd = (Texture)Resources.Load("button_control_end");
m_UITexturePrevious = (Texture)Resources.Load("button_control_previous");
m_UITextureStart = (Texture)Resources.Load("button_control_start");
+ m_UITextureNewHurtBox = (Texture)Resources.Load("hurtbox");
+ m_UITextureNewHitBox = (Texture)Resources.Load("hitbox");
styles = ActionEditorStyles.Get();
}
@@ -79,6 +83,25 @@ namespace ActionTool
GUI_Toolbar_Pause(ref x, ref y);
GUI_Toolbar_Next(ref x, ref y);
GUI_Toolbar_End(ref x, ref y);
+
+ GUI_DrawSeperateLine(x + 10 + kToolbarControlMargin, 0, kToolbarHeight);
+ x += 20;
+
+ GUI.enabled = ActionManager.animationData != null;
+ GUI_Toolbar_NewHurtBox(ref x, ref y);
+ GUI_Toolbar_NewHitBox(ref x, ref y);
+ GUI.enabled = true;
+
+ GUI_DrawSeperateLine(x + 10 + kToolbarControlMargin, 0, kToolbarHeight);
+ x += 20;
+
+ GUI.enabled = ActionManager.animationData == null;
+ GUI_Toolbar_NewAnimationData(ref x, ref y);
+ GUI.enabled = true;
+
+ GUI.enabled = ActionManager.animationData != null;
+ GUI_Toolbar_Save(ref x, ref y);
+ GUI.enabled = true;
}
void GUI_Toolbar_BG()
@@ -153,6 +176,28 @@ namespace ActionTool
x += kToolbarControlSize;
}
+ void GUI_Toolbar_NewHurtBox(ref float x,ref float y)
+ {
+ x += kToolbarControlMargin;
+ Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
+ if (GUI.Button(rect, new GUIContent("New", m_UITextureNewHurtBox)))
+ {
+ ActionManager.End();
+ }
+ x += kToolbarControlSize;
+ }
+
+ void GUI_Toolbar_NewHitBox(ref float x, ref float y)
+ {
+ x += kToolbarControlMargin;
+ Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
+ if (GUI.Button(rect, new GUIContent("New", m_UITextureNewHitBox)))
+ {
+ ActionManager.End();
+ }
+ x += kToolbarControlSize;
+ }
+
void GUI_Detail()
{
float y = kToolbarHeight + 5;
@@ -184,7 +229,7 @@ namespace ActionTool
Rect rect = new Rect(0, y, 20, 15);
for(int i = 0; i < sampleCount; i++)
{
- rect.x = kTimeLineViewXOffset + i * kFrameWidth - 7;
+ rect.x = kTimeLineViewXOffset + i * kFrameWidth - ((i >= 10) ? 7 : 3);
if(i % 5 == 0)
{
Color c = GUI.color;
@@ -193,7 +238,7 @@ namespace ActionTool
GUI.color = c;
}
}
- y += 15;
+ y += 11;
}
void GUI_Slider( ref float y)
@@ -221,7 +266,7 @@ namespace ActionTool
ActionData action = ActionManager.actionData;
int sampleCount = (int)action.totalFrame + 1;
- Rect bgRect = new Rect(kTimeLineViewXOffset, y, action.totalFrame * kFrameWidth, ActionManager.kMaxEventsPerFrame * kFrameHeight);
+ Rect bgRect = new Rect(kTimeLineViewXOffset, y, action.totalFrame * kFrameWidth, ActionManager.eventAndBoxCount * kFrameHeight);
GUI.Box(bgRect, "");
ui.defaultUIMaterail.SetPass(0);
@@ -234,7 +279,7 @@ namespace ActionTool
GL.Begin(GL.LINES);
Color lineColor = new Color(0.3f, 0.3f, 0.3f);
Color lineColor2 = new Color(0.5f, 0.5f, 0.5f);
- for (int i = 0; i < ActionManager.kMaxEventsPerFrame + 1; i++)
+ for (int i = 0; i < ActionManager.eventAndBoxCount + 1; i++)
{
ui.DrawHorizontalLineFast(y + i * kFrameHeight, kTimeLineViewXOffset, kTimeLineViewXOffset + action.totalFrame * kFrameWidth, lineColor);
}
@@ -243,15 +288,15 @@ namespace ActionTool
Color c = i % 5 == 0 ? lineColor2 : lineColor;
float x = kTimeLineViewXOffset + i * kFrameWidth;
x = Mathf.Clamp(x, kTimeLineViewXOffset, kTimeLineViewXOffset + action.totalFrame * kFrameWidth);
- ui.DrawVerticalLineFast(x, y, y + ActionManager.kMaxEventsPerFrame * kFrameHeight, c);
+ ui.DrawVerticalLineFast(x, y, y + ActionManager.eventAndBoxCount * kFrameHeight, c);
}
- ui.DrawVerticalLineFast(kTimeLineViewXOffset + bgRect.width * action.curAnimTimeNormal, y, y + ActionManager.kMaxEventsPerFrame * kFrameHeight, Color.red);
+ ui.DrawVerticalLineFast(kTimeLineViewXOffset + bgRect.width * action.curAnimTimeNormal, y, y + ActionManager.eventAndBoxCount * kFrameHeight, Color.red);
GL.PopMatrix();
GL.End();
- y += ActionManager.kMaxEventsPerFrame * kFrameHeight;
+ y += ActionManager.eventAndBoxCount * kFrameHeight;
}
void GUI_Events(ref float y)
@@ -259,6 +304,46 @@ namespace ActionTool
}
+ void GUI_DrawSeperateLine(float x, float y, float height)
+ {
+ ui.defaultUIMaterail.SetPass(0);
+ GL.PushMatrix();
+ GL.LoadPixelMatrix();
+ bool bWin = Application.platform == RuntimePlatform.WindowsEditor;
+ if (bWin)
+ GL.Begin(GL.QUADS);
+ else
+ GL.Begin(GL.LINES);
+ Color lineColor = new Color(0.3f, 0.3f, 0.3f);
+ Color lineColor2 = new Color(0.1f, 0.1f, 0.1f);
+ ui.DrawVerticalLineFast(x, y, y +height, lineColor2);
+ ui.DrawVerticalLineFast(x+1, y, y +height, lineColor);
+ GL.PopMatrix();
+ GL.End();
+ }
+
+ void GUI_Toolbar_NewAnimationData(ref float x, ref float y)
+ {
+ x += kToolbarControlMargin;
+ Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
+ if (GUI.Button(rect, new GUIContent("New")))
+ {
+ ActionManager.CreateAnimationData();
+ }
+ x += kToolbarControlSize;
+ }
+
+ void GUI_Toolbar_Save(ref float x, ref float y)
+ {
+ x += kToolbarControlMargin;
+ Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
+ if (GUI.Button(rect, new GUIContent("Save")))
+ {
+ ActionManager.SaveAnimationData();
+ }
+ x += kToolbarControlSize;
+ }
+
}
} \ No newline at end of file