Modyfing Sequencer.cs

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Strook
Posts: 70
Joined: Fri Nov 08, 2019 10:51 am

Modyfing Sequencer.cs

Post by Strook »

Hello!

I'm currently at the stage of my game where a lot of things has been done, and I gotta hack my way around... :shock:

Here is my situation: I have lots of conversation across my game, and I have been using the sequencer command "AnimatorPlay(animationName, animatorTarget, transition duration)" extensively

It works great but now I'm finding myself in a specific need: I want to call a specific function in one of my game scripts when the AnimatorPlay is called, and another function when the duration of the transition has passed.

My first guess was to try and modify (reluctantly, but I dont see any other solution) Sequencer.cs, more specifically the method "HandleAnimatorPlayInternally", and call my stuff just before animator.CrossFadeInFixedTime(...)

However here is my problem: I cannot manage to reference my own script in Sequencer.cs (or any other DS scripts). I'm guessing this is due to assembly definitions, but I unfortunately have no experiences with this and I am having trouble finding how can I reference my script there!


To go a bit more in details about WHY im doing this:

My characters are animated a specific way, with their body and faces all animated in single clips. The faces are 2D sprites that are animated with constant values. However when transitioning to another clip, the value used for the 2D sprites is blending too, so it create very weird motions. My goal is to completely prevent any blending whatsoever as soon as a "AnimatorPlay" is called, and resume the transition after the duration of the crossfade. Other animation cases like gameplay and cutscene are already handled another way, but I still need to find a solution for animations triggered from dialogue sequences.


This is a very specific problem, and probably not DS specific tho, but I'm still asking in case you can help :oops:
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Modyfing Sequencer.cs

Post by Tony Li »

Hi,

Scripts in Plugins folders can't see files that are outside Plugins. Unity compiles code in several separate passes, in this order:
  • Assembly-CSharp-firstpass: Files in Plugins, except for Editor folders
  • Assembly-CSharp-firstpass-editor: Files in Plugins that are in Editor folders (not included in builds)
  • Any folders with assembly definition files (none by default unless you or an asset has added them)
  • Assembly-CSharp: Files outside Plugins, except for Editor folders
  • Assembly-CSharp-editor: Files outside Plugins that are in editor folders (not included in builds)
However, I don't recommend directly modifying Sequencer.cs anyway.

What about writing your own sequencer command? For example, duplicate SequencerCommandAnimatorPlayWait.cs and call it something like SequencerCommandAnimate.cs. Modify it to prevent blending. Then use the Dialogue Editor's Database > Global Search & Replace to replace all "AnimatorPlay(" with "Animate(".
User avatar
Strook
Posts: 70
Joined: Fri Nov 08, 2019 10:51 am

Re: Modyfing Sequencer.cs

Post by Strook »

As always thanks for the great reply Tony,

I will do a copy of AnimatorPlayWait and do a global search & replace, it does sounds like the more reasonable option!
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Modyfing Sequencer.cs

Post by Tony Li »

Glad to help!
Post Reply