Search Unity

[Depreciated] Ultimate Replay - Complete state based replay system

Discussion in 'Assets and Asset Store' started by scottyboy805, Jun 28, 2017.

  1. Noa3

    Noa3

    Joined:
    May 29, 2012
    Posts:
    84
    Hardly to Explain, Ultimate Replay try to deactivate all Gameobjects thats right. but somehow the Inputscript is still activated and i cant do input in the GUI for Unity for Playback controll or after stoping the Playback, the mouse input, Keyboard input and even the Controller input is not working anymore because of that Inputscript activated before, and after a Scene Reload its Still Blocked.

    my idea was, if i reload the scene, and activate the Playback before the Input script got Activated, i can do normal the Playback.

    maybe we can meet together in Teamviewer?


    here is a Screen what is happen:


    i Play a bit, start a Record, and Press a Button: this Stop the record, load the scene(after scene reload the File got deleted) new and start in the Update() Call the Playback, after this i have 0 seconds recorded and can Probably do the Playback.

    here is the important Part of my Playback Manager:

    Code (CSharp):
    1.     // Update is called once per frame
    2.     void Update()
    3.     {
    4.         if (ReplayManager.IsReplaying == true)
    5.         {
    6.             //Do Playback Stuff here
    7.         }
    8.         else
    9.         {
    10.             if (PlayerPrefsX.GetBool("TestReplay", false) == true) {
    11.                 PlayerPrefsX.SetBool("TestReplay", false);
    12.  
    13.                 Debug.Log("Do Playback");
    14.  
    15.                 if (VB == null) {
    16.                     VB = FindObjectOfType<VehicleBase>();
    17.                 }
    18.  
    19.                 if (VB != null) {
    20.                     VPDeviceInput VPDI = VB.GetComponent<VPDeviceInput>();
    21.                     if (VPDI != null) {
    22.                         VPDI.enabled = false;
    23.                         Destroy(VPDI);
    24.                     }
    25.                 }
    26.  
    27.                 Cursor.visible = true;
    28.  
    29.                 PlaybackStartNew();
    30.             }
    31.          
    32.             if (player.GetButtonUp("ShowFastReplay") && ReplayManager.Target != null) {
    33.  
    34.                 if (ReplayManager.IsRecording) {
    35.                     ReplayManager.StopRecording();
    36.                     Debug.Log("StopRecord");
    37.                 }
    38.  
    39.                 PlayerPrefsX.SetBool("TestReplay",true);
    40.              
    41.                 Debug.Log("Load New Scene");
    42.                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    43.  
    44.             }
    45.          
    46.         }
    47.     }
    48.  
    49.     public void PlaybackStartNew() {
    50.  
    51.         if (ReplayManager.IsRecording) {
    52.             ReplayManager.StopRecording();
    53.         }
    54.  
    55.         ReplayPlayCanvas.SetActive(true); //canvas for GUI controll
    56.  
    57.  
    58.         if (VB != null) {
    59.             VPDeviceInput VPDI = VB.GetComponent<VPDeviceInput>();
    60.             if (VPDI != null) {
    61.                 VPDI.enabled = false;
    62.             }
    63.         }
    64.  
    65.         // Start playback
    66.  
    67.         if (ReplayManager.Instance == null) {
    68.             Debug.LogError("No Replay Manager!");
    69.         }
    70.         //Debug.Log(ReplayManager.Target.Duration);
    71.  
    72.  
    73.         ReplayManager.BeginPlayback();
    74.  
    75.     }
     

    Attached Files:

    • Log.jpg
      Log.jpg
      File size:
      2.2 MB
      Views:
      715
  2. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Ok I think I understand a bit better now. Is your replay script attached to a replay object of any kind. Ultimate Replay will only disable scripts that are attached to replay objects and anything else will be allowed to run. You should just be able to add a 'ReplayObject' script to the same game object as your input script and that will cause the replay system to disable it during playback.

    As for the file target issue: You have 'Overwrite Existing Files' enabled on the 'ReplayFileTarget' component which means that the file will be overwritten when you start recording again. If you disable it the file will not be deleted.
     
  3. Noa3

    Noa3

    Joined:
    May 29, 2012
    Posts:
    84
    ok i got the problem now to fix, the Replaymanager didnt destroy directly on Scenechange, so i put a "load" Scene betwen, detroyed the old replaymanager and load the scene again in the "Playback mode". now is working everything fine.
     
  4. Noa3

    Noa3

    Joined:
    May 29, 2012
    Posts:
    84
    my next question is, i want to record and Playback a Piece of UI Text.

    what is in this script wrong?
    Code (CSharp):
    1. using UltimateReplay;
    2. using UnityEngine.UI;
    3.  
    4. public class UR_Record_UIText : ReplayBehaviour {
    5.  
    6.     private Text text;
    7.     private string TextToWrite = "";
    8.  
    9.     // Use this for initialization
    10.     void Start() {
    11.         text = GetComponent<Text>();
    12.     }
    13.  
    14.     public override void OnReplaySerialize(ReplayState state) { //is Called On Record
    15.  
    16.         state.Write(text.text);
    17.     }
    18.     public override void OnReplayDeserialize(ReplayState state) { //is Called On Playback
    19.  
    20.         TextToWrite = state.ReadString();
    21.     }
    22.  
    23.     public override void OnReplayUpdate() {
    24.  
    25.         text.text = TextToWrite;
    26.     }
    27. }
     
  5. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Sorry for the delay. i didn't get a notification for your post.

    That script looks OK to me although you could do away with OnReplayUpdate and just read the data directly into your Text component in the OnReplayDeserialize method. The OnReplayUpdate method is only really used when interpolating between values. If the script does not seem to be working then I would check that you also have a ReplayObject component attached to the same game object.

    Alternatively you could also use the following code which makes use of Replay Variables which are serialized automatically:

    Code (CSharp):
    1.  
    2. using UltimateReplay;
    3. using UnityEngine.UI;
    4.  
    5. public class UR_Record_UIText : ReplayBehaviour {
    6.  
    7.     private Text text;
    8.    
    9.     [ReplayVar]
    10.     public string TextToWrite = "";
    11.  
    12.     // Use this for initialization
    13.     void Start() {
    14.         text = GetComponent<Text>();
    15.     }
    16.    
    17.     void Update()
    18.     {
    19.         if(IsRecording == true)
    20.             TextToWrite = text.text;
    21.        
    22.         if(IsReplaying == true)
    23.             text.text = TextToWrite;
    24.     }
    25. }
    26.  
     
    Last edited: Aug 22, 2018
    Noa3 likes this.
  6. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    I am also curious which way is better in terms of performance.
     
    Noa3 likes this.
  7. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    For best performance you cannot beat custom OnSerialize and Deserialize implementations. Replay variables reply on reflection for some aspects which can be slow and a lot of type checking is done for safety. Replay Variables are intended for ease of use where performance is not as important.
     
  8. nwxp

    nwxp

    Joined:
    Apr 4, 2017
    Posts:
    19
    Hello !


    I just bought your replay system and it's working perfectly for me ! That's some really nice work there.

    I saw in your documentation that future version will have animator support. I need this badly right now so I would like to know when this will be available and if you could send me a "kind of working" version that I could use.

    My animation are really simple, it's only some walk movement on a humanoid character (AI controlled).
     
    Last edited: Aug 23, 2018
  9. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    I am glad you are liking our asset so far :).

    We have actually implemented most of the Replay Animation and the code is packaged with the asset and has been for a few versions now. It is however considered experimental and may contain bugs and for this reason it is disabled by default. You can easily enable it however by adding the following scripting define symbol to your player settings: 'ULTIMATEREPLAY_EXPERIMENTAL'. Once you have added that define and Unity has recompiled the source code you will be able to record and replay animations that are handled by the Animator Unity component. You will simply add the component at 'UltimateReplay/ReplayAnimator' and then drag the Animator component you want to record into the 'Observed Animator' inspector field and you will be ready to go.

    Let me know if you need more detailed help on any of the steps.
     
  10. nwxp

    nwxp

    Joined:
    Apr 4, 2017
    Posts:
    19
    I tried what you said but there's no animation playing, and at the end of the replay, my character will walk to the previous point instead of the next one.

    Here's a video of what's happening in case i'm not clear enough :

     
  11. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    I forgot to mention earlier that the latest version of Ultimate Replay introduced a bug with the animation playback which caused the animator component to become disabled which is why your animation is not replaying. We have already created a patch for this but we have not yet submitted the update to the asset store as we are waiting on some other fixes. I have attached a small patch package which you can import into your project and should fix this issue.
     

    Attached Files:

    Noa3 likes this.
  12. Noa3

    Noa3

    Joined:
    May 29, 2012
    Posts:
    84
    thx i had allready written a c# script to turn the animator on again xD
    i thought this was maybe intended.

    mabye you can put something like this in a Example folder for other people?
    Code (CSharp):
    1. #if ULTIMATEREPLAY_EXPERIMENTAL
    2. using UltimateReplay;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class UR_Record_UIText : ReplayBehaviour {
    7.  
    8.     private Text text;
    9.     public bool HoldParentCanvasEnabled = true;
    10.  
    11.     [ReplayVar]
    12.     public string TextToWrite = "";
    13.  
    14.     private Canvas CS;
    15.     // Use this for initialization
    16.     void Start() {
    17.         text = GetComponent<Text>();
    18.     }
    19.  
    20.     void Update() {
    21.         if (HoldParentCanvasEnabled == true && CS == null) {
    22.             CS = gameObject.GetComponentInParent<Canvas>();
    23.             CS.enabled = true;
    24.             text.enabled = true;
    25.         }
    26.         else if (HoldParentCanvasEnabled == true) {
    27.             CS.enabled = true;
    28.             text.enabled = true;
    29.         }
    30.  
    31.         if (ReplayManager.IsDisposing == false) {
    32.  
    33.             if (IsRecording == true)
    34.                 TextToWrite = text.text;
    35.  
    36.             if (IsReplaying == true)
    37.                 text.text = TextToWrite;
    38.         }
    39.  
    40.     }
    41. }
    42. #endif
     
  13. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    No problem. You are correct that animators should be disabled during playback as they could interfere with the object but if you are trying to record via an Animator component then it must be enabled in order to replay the recorded animation. Previously all animators were disabled which would cause the problem you had.

    I got a notification about an error you were receiving about the replay manager being disposed but it looks like you deleted the post and found a solution. You should not have to check the is disposing property manually when inheriting from Replay Behavior. It is a bug and we will fix it in the next version so that the IsDisposed check is done via the property accessor so you will be able to use the properties whenever.
     
  14. Noa3

    Noa3

    Joined:
    May 29, 2012
    Posts:
    84
    wow thx, i looking forward to it!
     
  15. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Ultimate Replay 1.1.2 has been submitted to the asset store for review and should be available within a day or two. This version includes:
    • Fixed a threading error when building for web GL platform.
    • Added replay file support for web GL platform. Due to the limitations of the platform the file IO is performed on the main thread and will have a slight pause after recording and before replaying where file operations are done. It is also recommended to keep record duration's as small as possible.
    • Added support for 'dynamic prefabs' or prefabs instances that are spawned prior to recording. Previously these objects would not replay properly.
    • Fixed a bug where some prefab instances would be spawned at the origin during playback.
    • ReplayBehaviour properties now implement correct disposed checks for the active replay manager and should no longer generate errors about the replay manager being disposed.
    • Fixed a bug where Animator components would be disabled during playback even though they are needed by the ReplayAnimator component to replay animations correctly.
     
  16. nwxp

    nwxp

    Joined:
    Apr 4, 2017
    Posts:
    19
    I got errors with new version :

    Assets/UltimateReplay/Scripts/Core/StatePreparation/AnimatorPreparer.cs(15,31): error CS0117: `UltimateReplay.ReplayAnimator' does not contain a definition for `IsAnimatorObserved'

    Assets/UltimateReplay/Scripts/Core/StatePreparation/AnimatorPreparer.cs(28,31): error CS0117: `UltimateReplay.ReplayAnimator' does not contain a definition for `IsAnimatorObserved'
     
  17. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    If you delete the file 'AnimatorPreparer.cs' at 'Assets/UltimateReplay/Scripts/Core/StatePreparation/' does the error go away? That file should not have been included in the update and I don't know how it did get included. We don't have the error on our end because the file does not exist o_O
     
    nwxp likes this.
  18. nwxp

    nwxp

    Joined:
    Apr 4, 2017
    Posts:
    19
    That did it ! Thank you.
     
  19. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Great. An update will be submitted asap to fix this.
     
  20. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    I have a very strange case here.

    Most of the interpolation of ReplayTransform works well. However, one of my ragdoll character has no interpolation during replay.

    I tried to log `interpolate` and it is true. I then log `lastPosition` and `targetPositon`. Strange thing happens, here is the log:
    Code (CSharp):
    1. OnReplayDeserialize targetPosition.x=0.236 Time.realtimeSinceStartup=56.01653
    2. Before OnReplayReset lastPosition.x=0.1870001 targetPosition.x=0.236 Time.realtimeSinceStartup=56.01757
    3. After OnReplayReset lastPosition.x=0.236 targetPosition.x=0.236 Time.realtimeSinceStartup=56.01818
    The above is a normal one since lastPosition stores the last targetPosition value and targetPosition reads a new value from deserialization and so interpolation works

    This is a strange one:
    Code (CSharp):
    1. OnReplayDeserialize targetPosition.x=0.0554841 Time.realtimeSinceStartup=54.87974
    2. Before OnReplayReset lastPosition.x=0.02099996 targetPosition.x=0.02099996 Time.realtimeSinceStartup=54.88048
    3. After OnReplayReset lastPosition.x=0.02099996 targetPosition.x=0.02099996 Time.realtimeSinceStartup=54.88107
    After targetPosition reads the value 0.0554841 during deserialization, it suddenly becomes 0.02099996 when lastPosition tries to store it, so lastPosition equals to targetPosition and interpolation does nothing.

    I tried to figure out who changes the value of targetPosition and found that only OnEnable, OnReplaySpawned and OnReplayDeserialize do it. I logged all the places and found that only OnReplayDeserialize is called. Any idea?
     
  21. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    That is very strange, especially since it is working for your other objects.

    I don't really have any idea why that would be happening. I have looked at the source and as you say there is only a couple of places the values are modified. The only thing that could potentially cause this would be if 'OnReplayDeserialize' was called on the same frame for some reason but that should not be the case. It may be worth logging 'Time.frameCount' just to rule this out.

    If you like I could take a look at the project (or a reduced repro version) if you are willing to share it. Contact us at info(at)trivialinteractive.co.uk if you want us to take a look.
     
  22. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    My bad, I found another ReplayObject under the hierarchy. Things are fine now. Thanks.
     
  23. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Glad to hear you found the problem. I will look into adding a warning if there are multiple ReplayObject components on an object hierarchy to avoid this issue in the future.
     
    stevenwanhk likes this.
  24. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Ultimate Replay 1.1.3 has been submitted to the asset store and should be available for download within a day or two. This version includes:
    • The replay manager update method (Update, LateUpdate or FixedUpdate) can now be changed via the inspector window to offer better compatibility with other 3rd party assets such as cinemachine.
    • Fixed an import error in the trial version which caused editor scripts to not compile.
    • A few other small bug fixes.
     
  25. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    263
    Hey Scotty, just purchased after having a good experience with the trial. Really like what you have built! Thanks for making it and releasing.

    I'm running into some weirdness when reloading the current scene while a replay is running. I'm doing that in a prototype right now so that I don't have to manage resetting everything.

    Is there a proper series of things to do to shut down Replay Manager gracefully before reloading? I have tried keeping Replay Manager alive using DontDestroyOnLoad via that inspector option, but that just leads to even crazier things happening.

    Thanks
     
  26. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    I am glad you are liking our asset so far.

    If I understand correctly then you are trying to reload the scene during playback of a recorded replay? If that is the case I would recommend that you stop playback before the scene change and resume it afterwards but it should not cause too much of a problem even if you didn't bother doing that.

    When you have 'DontDestroyOnLoad' disable I expect that the ReplayTarget component where the recorded data is stored is being destroyed along with everything else in the scene resulting in a loss of the recorded data and when the new scene loads the recording is empty.
    When you have 'DontDestroyOnLoad' enabled I expect that the replay manager and ReplayTarget will survive the scene change but now a new ReplayManager will be created as part of the scene load causing 2 managers to exist. If this is the case then Ultimate Replay should give a warning in the console and dispose of one of these managers. This could cause a few major issues if the replay system destroys the wrong manager.

    Could you give a bit more information on what happens when the scene reloads. Any error messages in the console? playback not expected? or simply nothing happens?
     
  27. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    263
    Great thanks for the speedy reply.

    We're seeing these two things:

    Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
    The following scene GameObjects were found:
    ReplayManager

    ObjectDisposedException: The object was used after being disposed.
    UltimateReplay.ReplayManager.get_Instance () (at Assets/UltimateReplay/Scripts/ReplayManager.cs:192)
    UltimateReplay.ReplayManager.get_IsRecording () (at Assets/UltimateReplay/Scripts/ReplayManager.cs:321)
    UltimateReplay.ReplayManager.OnDestroy () (at Assets/UltimateReplay/Scripts/ReplayManager.cs:583)


    The game behaves... oddly. Can't quite enumerate the issues off the top of my head so figured I'd ask generally first.

    BTW I don't want the replay to live on in any way on scene reload. Just want a clean start. Makes sense that all the references would be trashed.
     
  28. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Thanks for the information.
    I will have to look into this further tomorrow when I can do some testing but I will let you know when I have some information.
     
  29. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    263
    Thanks. To be clear, I would like to gracefully stop the replay and the manager before reloading the scene. There is no requirement to carry the replay over. Everything should go back to the startup state.
     
  30. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi again,
    I managed to do some testing on this issue and could not seem to replicate the problem on my end. For the testing I used the demo scene 'CubeDemo' and created a simple script to reload the same scene at a number of points including during recording and during playback. There were no errors at all during this testing and I even tried changing the execution order of the ReplayManager to see if that affected anything but it did not. Would it be possible for you to send us the project you are using so we can trace the problem? If so then please send it to info(at)trivialinteractive.co.uk and we will look into it.
     
  31. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    I have similar issue as benthroop. The problem is recordOnStart in ReplayManager = true by default. So whenever the scene has no ReplayManger, everytime a new gameobject with ReplayObject is created, a new ReplayManager which has state equals to PlaybackState.Recording will be created. During this time if the ReplayObject is destroyed, RecordSnapshot in ReplayScene will raise Null Exception error because the ReplayObject inside dynamicReplayObjects is null.

    Setting recordOnStart = false by default seems be able to fix this though.
     
  32. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    263
    @stevenwanhk nice find. Unfortunately that didn't fix me. I think the root of my issue is that I'm instantiating an object in the replay and it doesn't handle that correctly.

    I can also say that the ObjectDisposedException in our case only happens when we exit Play Mode (and OnApplicationQuit hits in ReplayManager). So that is more of a symptom than an actual problem.
     
  33. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Thanks for letting me know. We should be able to fix the null reference exception fairly easily but we can also make the default value for ‘recordOnStart’ false if it is preferred.
     
  34. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    If an instantiated object is not being handled correctly then I would make sure that it has a ReplayObject script attached to it and that it is registered with the active Replay manager although you should see some errors in the console if this is the problem. If it is still not working the it is probably a bug but we will need some more information to try and fix it.

    The ObjectDisposedException only occurs when the active Replay Manager has been destroyed as a result of the game quitting but you are still trying to access it somewhere along the line. Normally a new instance would be created to avoid error but we cannot do that if the game is quitting. You can use the property 'ReplayManager.IsDisposing' to check whether it is safe to access the Replay Manager.
     
  35. unity_tFjIQOCTGfu3_A

    unity_tFjIQOCTGfu3_A

    Joined:
    Nov 1, 2018
    Posts:
    2
    Hello!

    I purchased this asset(into other account) and I have a problem. There is no problem with mobile builds, but the recording system does not work.

    Isn't it running on mobile(Android/IOS) from the beginning? or it only an Android path issue?

    I want to find the solution.

    Thanks.
     
  36. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    Are you getting any errors if you try a debug build? If you build one of the included demo scenes do they also fail to work as expected? We do not have any mobile devices to test on but our asset should still work on mobile as we took the platforms into account when developing Ultimate Replay and it uses only managed code.

    You say that it could be a path issue: Ultimate Replay only uses the file system when a ReplayFileTarget component is used to record to file so you can test if this may be the issue by swapping to a ReplayMemoryTarget to see if the error is eliminated.

    Hopefully we can find the problem and get it fixed.
     
  37. unity_tFjIQOCTGfu3_A

    unity_tFjIQOCTGfu3_A

    Joined:
    Nov 1, 2018
    Posts:
    2
    I fixed it as you said. It works fine.

    Thanks for the answer :)
     
  38. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Good to hear. Let me know if you have anymore issues.
     
  39. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Ultimate Replay version 1.1.4 has been submitted to the asset store for review and should be available to download within a day or two. This version includes:
    • Changed the way that dynamically spawned prefabs are handled to address some edge case issues.
    • ReplayObject prefabs identities will now be assigned when registered with a replay manager
    • A few minor bug fixes
    Unfortunately these changes mean that the replay file format had to be modified so this version will not be backwards compatible with previous replay files.
     
  40. Gatskop_Software

    Gatskop_Software

    Joined:
    Sep 21, 2014
    Posts:
    86
    Before I buy the asset question is it easy to record character animations. And is it easy to set up for the characters
     
  41. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    If you character is setup using a bone rig for animations then it is possible to record each bone on the character in order to capture animations. This method also has the added benefit of being able to record ragdolls. Alternatively you can record animations played via an ‘Animator’ component however this is still experimental and may contain bugs but is possible.

    I hope this helps you.
     
    Gatskop_Software likes this.
  42. Gatskop_Software

    Gatskop_Software

    Joined:
    Sep 21, 2014
    Posts:
    86
    I did buy the asset just now thanks for the replay I see you have under Experimental and demo scene but the dummy prefab is missing
     
  43. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    That prefab was only used for testing and we couldn’t include it because of copyright issues. I can update with a fully working example scene for animation but it will take a couple of days. In the meantime let me know if you need any help setting it up.
     
  44. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    Hi, I have this script working before I update to the latest version

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UltimateReplay;
    5. using System;
    6.  
    7. public class ReplayRecordActive : ReplayBehaviour
    8. {
    9.     public GameObject[] go;
    10.  
    11.     public override void OnReplaySerialize(ReplayState state)
    12.     {
    13.         if (IsRecording)
    14.         {
    15.             for (int i = 0; i < go.Length; i++)
    16.             {
    17.                 state.Write(go[i].activeInHierarchy);
    18.             }
    19.         }
    20.     }
    21.  
    22.     public override void OnReplayDeserialize(ReplayState state)
    23.     {
    24.         if (IsReplaying)
    25.         {
    26.             for (int i = 0; i < go.Length; i++)
    27.             {
    28.                 bool b = state.ReadBool();
    29.                 go[i].SetActive(b);
    30.             }
    31.         }
    32.     }
    33. }
    34.  
    After update, OnReplaySerialize is working normally, I can see data are recorded, but during playback, OnReplayDeserialize is never called. Anything I need to do to make it work? Thanks.
     
  45. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    That is a strange issue. Nothing has changed in the update relating to how serialization methods are called. There are only a couple of reasons I can think that this would happen:
    1. The gameobject the script is attached to is enabled while recording but gets disabled while replaying.
    2. Check that the ReplayObject component references this ReplayRecordActive component in its observed components list for both recording and replaying.
    If you could check these point then you may come across the problem. If you are still having trouble the would you be able to describe how the component is used. Ie is it a scene object or a prefab, does it get instantiated into the scene, is the component added dynamically etc.
     
  46. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    I simply attach this script to ReplayCube in your CubeDemo scene, assign ReplayCube to variable 'go' and after you 'Play', you can simply deactivate the cube, and play the playback. In the latest version of UltimateReplay, the ReplayCube was still there in the playback and behave strangely. I tried to revert the UltimateReplay with Git and try again, it worked.
     
    Last edited: Jan 17, 2019
  47. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    I traced the code and found that in CubeDemo, the replayObjects count in RecordSnapshot function is 1, but in PrepareForPlayback function, it's 0.
     
  48. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    113
    Ah wait, did we have the logic in (1) in last version? I'm pretty sure recording active state of gameObject worked in last version even the gameObject with script ReplayRecordActive attached is disabled during the recording
     
  49. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    I recreated the test scene as you described and after disabling the cube object I got the following warning in the console window when attempting to replay the scene:

    UltimateReplay_DisabledObjectWarning.png

    This is caused in the latest version only because the OnEnable/OnDisable events are used to add and remove the replay object from the recording list. In the previous version that you tested with the object would have been registered using Start/OnDestroy events which caused other issues so this is the change that has caused your script to stop working. The intended behaviour for future updates will be that disabled objects do not get recorded or replayed.

    I hope this helps you.
     
  50. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    An objects enabled state is not recorded however the state of its components are recorded before switching into record mode so that if they are enabled or disabled during recording they can be reset to their prior state.