0
Fixed

Macros change after undo

Kjartan 5 months ago • updated by Lazlo Bonin (Lead Developer) 2 weeks ago 19 1 duplicate

I am currently going through the platform tutorial (very nice tutorial btw), and I am noticing that some of my transistions and superunits that are set to macro change after I undo.

(I am at chapter 8 and I am currently setting up the "Chase" state.)

1. Here you can see how my patrol state looks like at first.

2. then I go into the "Chase" state and delete all the content, play the game, exit the game. I then go back to the "Chase" state and undo until all the content is back the way it used to be. When I go back into the "Patrol" state I find this:

two of the transitions have been changed.

3. I fix the transitions and go back to "Chase" to do another test. This time I create + delete a unit and then undo back to the way it was. I go back to "Patrol"  and now it looks like this:


So there seems to be an issue after invoking undo where it changes the contents of certain macros. This is just one example showing the issue with transitions, but I also had the same problem where a lot of superunits randomly got changed to a different type.

GOOD, I'M SATISFIED
Satisfaction mark by Kjartan 2 months ago

Duplicates 1

Here are some warnings that I am getting in the console. Not sure if they are relevant or not:


(Lazlo: Snipped)

+1
Under Review

Hi Kjartan!

I believe this is related to the bug with object reference being offsetted during serialization, which I thought I had fixed. This is very serious, so I'd like your help to reproduce it if you can!

Can you try "isolating" this behaviour to a simpler graph? Ideally, if you can give me step by step instructions to reproduce the bug from a new machine, it'd be ideal. Here Patrol is a triple nested state graph with 15 sub graphs, it's hard to pin point!

I'll do some attempts on my end at the same time.

Sure, I can see if I can reproduce the bug in a simpler setup tomorrow.

+2

Hi again, I started a fresh new project and I find that it is quite easy to reproduce the issue. 

Here I have a very simple State Machine with only one state, and I'm only using one type of Super Unit. 

Here's my starting point. I'm using the "Set Color" super unit to change the color of 3 objects named 1-3 to Red, Green and Blue.



I then select and delete the 3 super units on the left one by one, and then Ctrl+Z three times.

After that I end up with this:

So you can see that a lot of the super units loose their assigned macro. 

This is all happening within the same state, but I have noticed that this problem can affect any macro in any of the states within the same state machine.

 I also noticed that some times the assigned inputs within the "Set Color" super unit are changed too.  So instead of being 1,2,3 / RGB they are 3,1,2 /  RGB (just as an example).

It's worth mentioning that I don't always get the same result after deleting those 3 units and undoing 3 times. It always seems to change the units every time I try, but in slightly different ways each time.

This is how the simple "Set Color" macro looks like in case you need to know:


I hope that is a good enough example to recreate the problem.

Cheers!

Kjartan

Thanks for taking the time to write an example.

I tried reproducing exactly this, but I don't get any weird change when undoing.

How exactly is your state machine setup?

  • Is its source set to macro or embed?
  • Is it on a prefab?
  • Where are you editing it "from" (what do you select to display the graph): the macro (in the assets folder), the prefab / object instance (in the scene), the prefab definition (in the assets folder)?

Edit: I've been able to reproduce it by assigning scene object references to the input of the 3 set color super units on the left.

Yeah, I should maybe have mentioned that I assigned 3 cubes as scene object references. Also the state machine is also just applied to an empty gameobject and it is set to embeded. I didnt use any prefabs at all.

+2

Update: Found when the bug was occuring, but not why.

Basically, Unity is changing the order of the object references in the serialized data on the undo stack in between the undo record and the undo action. I'm a bit dumbfounded, as this should not happen at all. 

I'll investigate further to see if this is a Unity bug or a Bolt bug. This remains a high-priority issue for me.

Adding a warning about this since it may "corrupt" your graph:

If ever your references get moved around, however, it appears that redoing (Ctrl+Y) puts them back in their right place.

This remains a top-priority issue, but I'm still unsure why it is happening or how to fix it.

Under Review

I think this issue is related to the macro order changing upon serialization, I'll merge the threads.

Going back to fixing that bug as a priority.

+2
Fixed in Alpha

Well, this took 3 months of debugging to figure out why, but one line to fix:

Undo.RecordObject

Simply had to become:

Undo.RegisterCompleteObjectUndo

More explanation here: https://gist.github.com/lazlo-bonin/a85586dd37fdf7cf4971d93fa5d2f6f7

This will be fixed starting from the next version.

Congrats! You showed that bug who's boss :)

Finally! Now it will be okay to undo/redo stuff in graphs! ♥‿♥

Is this fix in the latest version on the asset store yet? I just bought bolt a couple of days ago but I'm still seeing the warning message.

+1

The fix is in place in the v.1.3.0 Beta, which will be pushed to the asset store as a stable release within the next two weeks. In the mean time, you can download it from here: http://ludiq.io/bolt/builds