I use FSM in NPC/Quest system,and I want to serialize current state data as SaveData.
At first,I serialize FSMState UID and can find certain node by UID,but find that the UID for the same node has changed when starting game in next time.
So,the UID for FSMState isn’t persistant but only unique in one play.
Does anyone know what property can be used as PersistantIndex?
The way UID works now, is that one is generated only when it is requested and if that UID is requested in runtime, then it is not serialized. Thus the next runtime session one is requested a new one is generated. I could change this behaviour so that a UID is always generated when the node is created and this way it will be serialized and persistent. The only reason I haven’t done this already is to avoid generating UIDs for nodes that we don’t need a UID for and thus speed up deserialization.
Now I know well about your design for UID.It seems to be my fault to use UID as a serializable property. What I want is to remember what is the current node/fsmstate of one graph,then save game data and serialize certain property of the node .The next runtime session,I deserialize the property, and enter state of the very node/fsmstate .
Now I use the name of the node/fsmstate and serialize it into my own class. When loading save data,I just load graph behaviour ,foreach all nodes and find the very one whose name is the same. I just think this way is not so such smart,and hope to use internal methods .
UIDs are now generated only when they are requested, and if they are requested during runtime, they are not serialised. When one is requested in the next runtime session, a new one is produced.