ddionisio / MateAnimator

Adding more features to the open sourced Animator from Unity.
113 stars 29 forks source link

Cutscene Editor uneditable after Method with Enum parameter deleted #17

Closed igrir closed 8 years ago

igrir commented 8 years ago

Step to reproduce:

  1. Create a script with public method in it (eg: TestScript.cs)
  2. Add Event track to the cutscene editor with the previously made script
  3. Delete the method and the enum from the script
  4. The cutscene editor unclickable and the console show errors every update

If I re-added the method, the cutscene editor works again. This issue wasn't happened if I use method without enum paramter in it.

Here's the error of the issue:

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
System.String.Substring (Int32 startIndex, Int32 length) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/String.cs:348)
MateAnimator.AMEventData.GetTypeFrom (System.String TypeName) (at Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs:204)
MateAnimator.AMEventData.getParamType () (at Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs:232)
MateAnimator.AMEventParameter.getParamType () (at Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs:439)
MateAnimator.AMEventData.get_val_enum () (at Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs:68)
MateAnimator.AMEventParameter.getStringValue () (at Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs:481)
MateAnimator.AMTimeline.getInfoTextForAction (MateAnimator.AMTrack _track, MateAnimator.AMKey _key, Boolean brief, Int32 clamped) (at Assets/MateAnimator/Editor/AMTimeline.cs:5344)
MateAnimator.AMTimeline.showFrames (MateAnimator.AMTrack _track, System.Single& track_y, UnityEngine.Event e, Boolean birdseye, Vector2 scrollViewBounds) (at Assets/MateAnimator/Editor/AMTimeline.cs:2989)
MateAnimator.AMTimeline.showFramesForGroup (Int32 group_id, System.Single& track_y, UnityEngine.Event e, Boolean birdseye, Vector2 scrollViewBounds) (at Assets/MateAnimator/Editor/AMTimeline.cs:2586)
MateAnimator.AMTimeline.OnGUI () (at Assets/MateAnimator/Editor/AMTimeline.cs:1945)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
ddionisio commented 8 years ago

Odd, tested that case as well while putting in failsafe for enum. That was the error the editor was getting when the enum is deleted or changed in some fashion.

The latest pull should only give you this message: "Parameters have been changed, from code? Attempting to restore data."

igrir commented 8 years ago

Yep! Yes it does if I only deleted the method (and if I deleted one of the enum it would change to other available enum). But this error shows up if I deleted both the enum and the method.

ddionisio commented 8 years ago

Ah I didn't realize you have to remove both function and enum at the same time. I've added another by-pass to an exception when a type is not found in code (these are fine to ignore, since a log is given later). See if it works now.

Event can be fragile if not careful, hence why I decided to add Trigger track a while ago for a more safer alternative. But Event still allows for less error (mistypes) during production.

igrir commented 8 years ago

I've just tried it again and here's some of errors I've found:

Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs(204,58): error CS0103: The name `endInd' does not exist in the current context

Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs(204,45): error CS1502: The best overloaded method match for `string.Substring(int, int)' has some invalid arguments

Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs(204,45): error CS1503: Argument `#2' cannot convert `object' expression to type `int'

Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs(208,59): error CS1502: The best overloaded method match for `System.Reflection.Assembly.Load(string)' has some invalid arguments

Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs(208,59): error CS1503: Argument `#1' cannot convert `object' expression to type `string'

Assets/MateAnimator/Scripts/Classes/AMEventParameter.cs(211,33): error CS1501: No overload for method `GetType' takes `1' arguments

Cheers!

ddionisio commented 8 years ago

Oops! Missed that on merge, should compile now.

igrir commented 8 years ago

Did the enum supports pruned? But it's great anyway and safe. I'll closed this.