change property in instantiated prefab fix

This commit is contained in:
2016-08-28 21:28:29 +07:00
parent 31b30e42c3
commit db8bc5e13c
2 changed files with 26 additions and 6 deletions

View File

@@ -37,10 +37,14 @@ namespace FlashTools.Internal {
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
if ( Application.isPlaying ) {
DrawAnimationControls();
}
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
}
}

View File

@@ -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();