mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2026-03-22 04:44:08 +07:00
change property in instantiated prefab fix
This commit is contained in:
@@ -37,10 +37,14 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
DrawDefaultInspector();
|
||||
if ( Application.isPlaying ) {
|
||||
DrawAnimationControls();
|
||||
}
|
||||
if ( GUI.changed ) {
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,22 @@ namespace FlashTools.Internal {
|
||||
public class SwfAnimationEditor : Editor {
|
||||
SwfAnimation _animation = null;
|
||||
|
||||
SerializedProperty GetCurrentFrameProperty() {
|
||||
var prop = serializedObject.FindProperty("_currentFrame");
|
||||
if ( prop == null ) {
|
||||
throw new UnityException("SwfAnimationEditor. Not found current frame property");
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
|
||||
void DrawCurrentFrame() {
|
||||
if ( _animation.frameCount > 1 ) {
|
||||
var new_current_frame = EditorGUILayout.IntSlider(
|
||||
"Frame", _animation.currentFrame,
|
||||
0, _animation.frameCount - 1);
|
||||
if ( new_current_frame != _animation.currentFrame ) {
|
||||
_animation.currentFrame = new_current_frame;
|
||||
}
|
||||
Undo.RecordObject(_animation, "Change SwfAnimation frame");
|
||||
EditorGUILayout.IntSlider(
|
||||
GetCurrentFrameProperty(),
|
||||
0,
|
||||
_animation.frameCount - 1,
|
||||
"Frame");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,19 +31,27 @@ namespace FlashTools.Internal {
|
||||
GUILayout.FlexibleSpace();
|
||||
{
|
||||
if ( GUILayout.Button(new GUIContent("<<", "to begin frame")) ) {
|
||||
Undo.RecordObject(_animation, "Change SwfAnimation frame");
|
||||
_animation.ToBeginFrame();
|
||||
EditorUtility.SetDirty(_animation);
|
||||
}
|
||||
if ( GUILayout.Button(new GUIContent("<", "to prev frame")) ) {
|
||||
Undo.RecordObject(_animation, "Change SwfAnimation frame");
|
||||
_animation.ToPrevFrame();
|
||||
EditorUtility.SetDirty(_animation);
|
||||
}
|
||||
GUILayout.Label(string.Format(
|
||||
"{0}/{1}",
|
||||
_animation.currentFrame, _animation.frameCount));
|
||||
if ( GUILayout.Button(new GUIContent(">", "to next frame")) ) {
|
||||
Undo.RecordObject(_animation, "Change SwfAnimation frame");
|
||||
_animation.ToNextFrame();
|
||||
EditorUtility.SetDirty(_animation);
|
||||
}
|
||||
if ( GUILayout.Button(new GUIContent(">>", "to end frame")) ) {
|
||||
Undo.RecordObject(_animation, "Change SwfAnimation frame");
|
||||
_animation.ToEndFrame();
|
||||
EditorUtility.SetDirty(_animation);
|
||||
}
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
Reference in New Issue
Block a user