Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

[Released] Ultimate Replay - Complete state based replay system

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

  1. flomaaa

    flomaaa

    Joined:
    Apr 12, 2019
    Posts:
    3
    Hi @scottyboy805, thanks for outlining this. I'll talk with the others from our research group to see what we are going to do in the near future - but the asset you provide looks really valuable for us. Thank you for providing it! Regarding your other points: That is strange.. that is not the behaviour I've faced. I need to resize the window every time to get the GUI working, however, not a big deal! :)
     
  2. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    No problem.
    I am not sure what could be causing the GUI scaling problem. All I could think of would be some script modifying the GUI matrix. Apart from that I am not sure what the issue could be as it seems to be working perfectly on our end with no scaling issues.
     
  3. qerdoriovox

    qerdoriovox

    Joined:
    Oct 16, 2019
    Posts:
    1
    Hi, @scottyboy805,
    I have already bought your plugin. The format of the recording is ReplayData.replay.
    What I should do to use uitimate replay to share the record video to youtube so that others can see it?
    Is the data ReplayData.replay can only be review in the game?
     
  4. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    HI,
    Yes the file format is only usable by Ultimate Replay and cannot be converted to any video formats because it does not contain the necessary data. The file format only stores object data such as positon and rotation so that it can recreate the scene at a later date. All playback is rendered at realtime. You will need to use another tool that can generate an mp4 file from the cameras rendering while playback is occuring to achieve what you want.

    I hope this help you. Let me know if you have any more questions.
     
  5. justaddice83

    justaddice83

    Joined:
    Sep 19, 2012
    Posts:
    30
    I am a paid user.

    What I would like is record from 2 prefabs that contain several ReplayTransform classes on them. I then want Replay on a mock up scene, with non-prefab objects (they are slightly different to the Prefabs), that have the same ReplayTransform.

    I've managed to manually update the non-prefab object ReplayIdentity.Id values (there are 20+), in which case the replay works perfectly.

    However the problem is the Ids change everytime I record from the Prefab based scene. This very time-consuming to manually update.

    What would be the best way to seed, or otherwise generate the same Ids each time on the Prefab based scene?

    I am looking through the code, but my initial attempt to seed ids did not work.

    Your help would be appreciated.

    Thank you.


    Update:
    I had a bit more of a hack on added the following to ReplayBehaviour and ReplayObject
    classes:

    Code (CSharp):
    1.  
    2.     public bool SerialIds = false;
    3.     public virtual void Awake()
    4.     {
    5.         if( SerialIds == true)
    6.             replayIdentity = new ReplayIdentity(ReplayIdProvider.GetNextId());
    7.  
    8.         ReplayIdentity.RegisterIdentity(replayIdentity);
    9.         ...
    10.  
    Depends on this new class:
    Code (CSharp):
    1. namespace UltimateReplay
    2. {
    3.     public class ReplayIdProvider
    4.     {
    5.         private static int idHead = 23000;
    6.         public static int GetNextId()
    7.         {
    8.             idHead++;
    9.             return idHead;
    10.         }
    11.     }
    12. }
    This is not quite working however.

    Curious if you may have a better way to do this as you are more familiar with how the ReplayIdentity class works.

    Update 2:
    This now works if I take a copy of the Prefabs (from the scene), while recording, and them paste them into the playback scene, make the changes and change SerialIds = false in the inspector. I have no idea why and doubt this is a robust solution.
     
    Last edited: Nov 4, 2019
  6. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi,
    This is not something that is currently supported and requires a bit of work as you have discovered. The replay ID of an object is assignable so it would probably be better for upgradability if you left the ReplayIdentity class alone and added an extra script to handle your custom ID's and assign as needed. I have not tested but something like this should work OK:

    Code (CSharp):
    1. using UnityEngine;
    2. using UltimateReplay;
    3.  
    4. class CustomID : MonoBehaviour
    5. {
    6.     static int idGenerator = 0;
    7.  
    8.     void Awake()
    9.     {
    10.         GetComponent<ReplayObject>().ReplayIdentity = new ReplayIdentity(idGenerator++);
    11.  
    12.         foreach(ReplayBehaviour replay in GetComponentsInChildren<ReplayBehaviour>())
    13.         {
    14.             replay.Identity = new ReplayIdentity(idGenerator++);
    15.         }
    16.     }
    17. }
    You would just attach this script to the prefab at the same hierarchy level as the ReplayObject component and it should sequentially assign ids.

    Also there are ReplayID's for all recorder components such as ReplayTransform so you will need to ensure that they remain the same as well. This is handled in the above script by enumerating all ReplayBehaviours (The base class for all recorded components).
     
    Last edited: Nov 4, 2019
  7. sourav4000

    sourav4000

    Joined:
    Jun 14, 2014
    Posts:
    10
    Hello @scottyboy805,
    I would like to use this asset to create a Killcam for Multiplayer FPS (using Modular Multiplayer FPS Engine from Asset Store). I downloaded the trial and attached ReplayObject & ReplayTransform/ReplayAminator to few prefabs. My problem is that I want the whole scene to be recorded and replayed on demand. It is very tedious to attach the record scripts to all prefabs and gameobjects and their children in the scene so, is there any automated option to accomplish this.

    Also, I would like to get some advice on using this asset with my existing setup Photon PUN.
     
  8. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi,
    There is no automated way to add the replay components however since they are just normal script components you can write a simple editor script to do this. I may be able to help you out with this when I have more time but you should be able to just create a menu driven editor script which cycles through all objects in the scene and adds the necessary replay components. Also you say you want to record the whole scene. You may already know this but I would not recommend recording objects that are not going to be moving (or animated in some way) as that would just waste memory and performance. You may be able to filter non-moving objects in an editor script by checking if the object is marked as static. Ofcourse if you use this approach you will need to ensue that scene objects are properly identified as static or not.

    As for the networking help: Did you receive the email we sent to you on the 7th of this month? I can go into more detail if needed.
     
  9. sourav4000

    sourav4000

    Joined:
    Jun 14, 2014
    Posts:
    10
    Thank You for that suggestion I was thinking the same.

    No, I did not receive your email regarding this. Please, guide me on this.

    I would also like to discuss another aspect that is about ReplayAnimator. I think it is in experimental stage therefore I don't expect it work bug free but can you suggest me an alternative to it. Like can I add ReplayTransform to Skeleton(Bones) GameObjects and observe them with a ReplayObject on root of player.

    What I want to achieve is simple when a player is killed I want to show a killcam replay similar to COD following a projectile from killer to player. BTW spawned object can be replayed quite good with your asset.
     
  10. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    I am away from the office now but I can resend the email or pm you on the forum. Maybe check your spam folder too incase it ended up there.

    Regarding the animation: Yes the replay animator is experimental and does lack some features but if you are using rigged animation then you would probably be better off just using the ReplayTransform component on all joints. This has the added benefit of being able to record ragdolls if you are using them. If you use this approach then you should only add one ReplayObject component to the root level of the object and it will manage all child recorders.

    A killcam like COD will certainly be achievable using our asset :)
     
  11. sourav4000

    sourav4000

    Joined:
    Jun 14, 2014
    Posts:
    10
    Hello @scottyboy805,

    I believe that PhotonView Script is not disabled by the default preparer.

    What I was thinking can we destroy the components other than Transform and MeshRenders while playback. This is only possible if we can always instantiate a clone of the ReplayObject when it comes to ReplayScene (BTW all my ReplayObject are prefabs). Manipulating the original clone by disabling/enabling scripts does not make sense as it is networked. When we go live it will not be at same place that it was before starting playback.

    Please, help me in this.

    This is working good.

    Another problem I discovered that I have few prefabs (Weapons) which are instantiated as child of another prefab (Player) while recording but this Parent - Child relationship is not maintained in playback. Is it possible to also record this event of parenting or detaching child?
    As after the player is killed the Player Third Person View (a prefab) is detached from Player (another prefab).

    I appreciate a response from you.
     
    Last edited: Nov 14, 2019
  12. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi,
    The PhotonView component should be handled by the default replay preparer as it is just a mono behaviour script. If it is not working then it sounds like a bug.

    Disabling components should be fine for this purpose. I would suggest that your multiplayer objects just need to listen for playback end events and resync object positions over the network and that should solve the problem. I am not overly familiar with photon but I can try and help with this if needed.

    Maintaining object parents during playback is supported but there are some requirements: The child object (the weapon in this case) must have a replay object component plus any recorder components required such as ReplayTransform. The immediate parent object (the players hand bone I would imagine) must have a ReplayObject component attached but requires no other replay components (unless needed). If the transform of the child is being recorded you should make sure it is set to use local position if the parent object is also recording its transform.

    I hope this helps you. Let me know if you have any more questions.
     
  13. sourav4000

    sourav4000

    Joined:
    Jun 14, 2014
    Posts:
    10
    In this way the parent-child relation is correct but for few players and not for others (same prefab). I believe it is due to Script Execution Order. So, which scripts should I add after default time? only ReplayManager or else?

    Edit: You can see in the screenshot (Paused playback of a recording) that one player has the weapon attached to WeaponInHandHolder GB but other weapons are on root (Shotgun_TP, etc.)

    BTW I am setting all ReplayTransform to local.
     

    Attached Files:

    Last edited: Nov 14, 2019
  14. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    HI again,
    I assume that your weapon game objects have a ReplayObject script attached too? If that is the case then it looks like there may be a bug because the ReplayObject for the 'WeaponsInHandHolder' is picking up recorder components on the weapon objects (BARR_TP and Pistol_TP). This should not happen. The weapon objects components should be registered only with the ReplayObject script attached to the weapon game object. Ie. if you have a ReplayTransform on the BAAR_TP object is should be managed only by the ReplayObject component attached to the same object and not the 'WeaponsInHandHolder' object. I hope that makes sense.
     
  15. sourav4000

    sourav4000

    Joined:
    Jun 14, 2014
    Posts:
    10
    Yes, that makes sense. I have ReplayObject on Player GB (Parent of All) observes all the transform components down to BAAR_TP when it is instantited as a child. So, can I solve this bug if I get the Full Version.

    I have noticed another glitch that is in playback mode when the child prefab clone is instantiated it comes from far space stretching the mesh wierdly. I think it is caused by the same bug.

    It works great when only one ReplayObject is at root and all child has ReplayTransform but I have prefab as child therefore it is compulsory to add ReplayObject to them. So, it is a kind of deadlock.
    What do you think?
     
  16. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    We will have to look into this further as it is not intended behaviour. The trial version and the full version share mostly the same codebase so upgrading will not fix the issue unfortunately. I don't know what to suggest in the meantime but we will work on this as soon as possible.
     
  17. sourav4000

    sourav4000

    Joined:
    Jun 14, 2014
    Posts:
    10
    It would be great if that is fixed quickly. Meanwhile can I extend ReplayObject and implement this ReplayObject. RebuildComponentList Method to not observe ReplayTransform of child and its children with ReplayObject. I hope this works. What do you think?
     
  18. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi again,
    I believe we have now fixed this issue. If you send an email to info(at)trivialinteractive.co.uk then we can send you an update with the fix so we can confirm that everything is working properly on your end too. It will save a few days waiting for the asset store approval process.
     
  19. Driven

    Driven

    Joined:
    May 31, 2013
    Posts:
    68
    @scottyboy805 how can i manually record a "frame"? The replay manager only offers Update, LateUpdate and FixedUpdate :(. What i'm doing is simulate my game within a for loop in 1 frame, with AI behaviour ticks etc and i want the replay manager to record in every loop tick, afterwards i want to play the result. If this is not possible, are you able to expose to internaly called "capture frame" function if it'S not already done somewhere?
     
  20. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi,
    This is not something that can be done easily at the moment. You could modify the code slightly to allow you to record a frame whenever you call a method but the biggest problem would be that Ultimate Replay relies upon Time.delteTime for issuing snapshots with a timestamp value. If you were to record a lot of snapshots in the same frame then the playback would not work properly because all frames would share the same timestamp.
     
  21. Driven

    Driven

    Joined:
    May 31, 2013
    Posts:
    68
    So is it somehow possible additionally with calling it manually to replace time.deltatime with "MyTime"? I have a tickrate of let's say 100ms, the for loop calls Tick(100ms) with every loop and moves the objects with this delta time. After each Tick i want to capture the positions, rotations etc with the plugin. So actually what i need is the possibility to call the capture method and pass a timestamp (or a tickrate ) myself ..? if it is not possible i will have to write my own replay thing i guess but it would be nice to have feature for your plugin i think.
     
  22. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi,
    I have looked into this a bit further and it looks like we may be able to modify the code to support manual calls to record snapshots while specifying the delat time. Would you be interested in testing this when we have it ready to see if it is what you need. If so just email us at info(at)trivialinteractive.co.uk with your invoice number (unless you are using the trial version) and we can send updates directly with the necessary changes.
     
  23. Driven

    Driven

    Joined:
    May 31, 2013
    Posts:
    68
    I would be interested in testing this! right now i was using the free version to see if it fits my needs but if it will support my use case i would of course purchase a copy (if it really works). The use case would look like this:

    Code (CSharp):
    1. while(!done){
    2.     AI.Tick(deltaTime);
    3.     //ReplayManager.Tick(deltaTime);
    4. }
    5. //Play the record
    Just tell me when it's ready and / or i have to buy the plugin.
     
  24. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    OK thats good. We actually already have a version ready for testing if you are able to as the changes were not that challenging. You will need to manually call 'ReplayManager.UpdateState(float)' when you want to record a snapshot, passing the delta time as an argument. I will also mention that 'UpdateState' as indicated by the name is a state based method. It will update the replay manager based on its current state such as Recording, Paused, Playback etc. You should make sure that you begin recording before manually calling the method otherwise you could be updating the playback sequencer or other sub systems. If you send a quick email to info(at)trivialinteractive.co.uk we can send you the modified trial version for testing.
     
  25. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    Hello @scottyboy805, I'm a paid user.
    I was just wondering whether it is possible to record a 'hierarchy' Transforms, e.g. something like:

    Code (CSharp):
    1.  
    2. --root
    3.   |-- a
    4.     |-- a1
    5.     |-- a2
    6.   |-- b
    7.     |-- b1
    8.     |-- b2
    9.  
    (I'm using code block to keep indent)

    Is it possible to record this whole bunch of Transforms with a single call to the 'root'?
     
  26. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    HI,
    Yes this is possible.
    You will need to add a ReplayObject component to the 'root' object and then recorder components such as ReplayTransform to all child objects that you want to record. You should see in the ReplayObject inspector that all the child components are automatically added to the observed component list. This works for any hierarchy depth.

    By single call do you mean that you want to add the components to all child objects in one click? If so this is not possible without writing a simple editor script.
     
  27. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    Thanks for the quick reply! It answers all my questions :)
     
  28. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    Hello @scottyboy805, it's me again ;)

    Sorry for the disturbing but I really want to know if I could 'inject' the recorded hierarchy Transforms back to 'root', without replaying it?

    So basically I want to do something like 'save & load' with this great asset. I think it is capable (because I think 'save & load' should be much easier than recording), but I failed to find the answer in the document :( (or maybe my poor English prevent me from finding one :rolleyes: )

    Edit: I've founded ReplayMemoryTarget.RecordSnapshot method which might be relevant, but there're few examples I could find in the user guide, so it will be so helpful if you could provide me with some links or codes, thanks in advance!
     
    Last edited: Dec 10, 2019
  29. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi, I'm not sure I understand what you want to do. Do you just want to record one frame and then playback that frame onto another replay object with the same hierarchy structure or something else? The ReplaySnapshot method may be useful if this is what you want.
     
  30. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    Basically, yes, but not onto 'another' replay object - instead, onto itself. I think what I want to do is quite 'simple', but I just can't find a way to do it :(

    1) animate a 'root' with lots of children to a certain state (let's call it A)
    2) record the hierarchy Transforms in state A with a memory target (or snapshot, because I only need one frame)
    3) animate 'root' to another state (let's call it B)
    4) switch 'root' hierarchy Transforms from B to A

    I've struggled for a long time and just cannot find a solution :(
     
  31. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    OK I think I kind of understand what you mean now. Will there be other ReplayObjects in the scene or just this one object because the only real way to achive this would be to use the ReplayManager which will also record all active replay objects. If there are other replay objects in the scene that you dont want to record you can either set thier ReplayObject scripts to disabled or manually call 'ReplayManager.Scene.UnregisterReplayObject' and pass in each game object which should not be recorded. Let me know fi you need more information or if I have the wrong idea.
     
  32. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    I'll make sure that all replay objects are wanted to record :) Because basically what I want to do is 'take a snapshot on a couple of objects (in state A), and then restore them back to state A after some time'

    However I really don't know how to achieve this after reading the user guide again and again :( It would be so kind of you if you could provide me some links or resources, thanks!!
     
  33. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    The only real way to achive this at the moment would be to use the ReplayManager in a slightly different way. You could use the ReplaySnapshot class to do this but it would need much more manual setup and is a bit more involed so I would say stick with the ReplayManager as it makes thing much easier. Here is a quick code example which should achieve what you want:

    Code (CSharp):
    1.  
    2. using UltimateReplay;
    3. using UltimateReplay.Storage;
    4.  
    5. public class Example : MonoBehaviour
    6. {
    7.     private int recordFrame = -1;
    8.  
    9.     // Assign in inspector
    10.     public ReplayMemoryTarget storageTarget;
    11.  
    12.     public void RecordSnapshot()
    13.     {
    14.         ReplayManager.Target = storageTarget;
    15.         ReplayManager.BeginRecording();
    16.         recordFrame = Time.frameCount;
    17.     }
    18.  
    19.     public void ReplaySnapshot()
    20.     {
    21.         ReplayManager.Target = storageTarget;
    22.         ReplayManager.SetPlaybackFrame(0f, PlaybackOrigin.Start);
    23.         ReplayManager.BeginPlaybackFrame();
    24.     }
    25.  
    26.     public void Update()
    27.     {
    28.         if(ReplayManager.IsRecording == true && Time.frameCount > recordFrame)
    29.             ReplayManager.StopRecording();
    30.     }
    31. }
    Note that the ReplayManager is not really intended to record singleframes but we can achive it with a few state checks. Essentially you would call 'RecordSnapshot' which will start the recording process but this script will automatically end recording on the next frame so only a single snapshot will be stored in the memory target. Then you can call 'ReplaySnapshot' when required which will switch to playback mode and set the first frame in the recording as active.
     
  34. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    Thank you so much for the detailed reply!!! This definitly saves my whole day!!! :D
     
  35. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    No problem. Let me know if there is anything else.
     
  36. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    One last question ( maybe? :rolleyes: ), is it possible now to access the raw data of the recorded hierarchy Transforms (let's say, a byte[] ), or save the raw data to a file? I've noticed in the user guide that We will be adding a ‘Replay File Target’ in the near future, but maybe there will be some surrogates for me to save the hierarchy Transforms?

    It is completely OK to use the ReplayMemoryTarget only (and that is also my near plan), but it will be awesome if saving hierarchy Transforms (in a byte[] like format) and restoring them is available, thanks!!
     
  37. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Its not possible to access the recorded data as a byte array exactly but there is a mistake in the documentation because the replay file target has been release for quite a while now so we will fix that. Just remove the ReplayMemoryTarget component that you are using and replace it with a ReplayFileTarget component to stream the replays to and from file.
     
  38. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    That's good news! Is there any document I can read about ReplayFileTarget? I've bought the asset but neither the user guide nor the scripting reference has any information on it :(
     
  39. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    We will have to update the documentation to fix this but it is a plug and play component and it is not really necessary to work with it directly. If the component is attached to the same game object as the ReplayManager then it will be automatically picked up and used when you make calls to the ReplayManager.
     
  40. carefree0910

    carefree0910

    Joined:
    Nov 12, 2019
    Posts:
    9
    That's very cool! I'll play with it in no time :) Again thanks for your nice and detailed replys! They really help me A LOT !!!!! :D
     
  41. justinleavesley

    justinleavesley

    Joined:
    Jul 14, 2013
    Posts:
    2
    Hi,

    I am using the paid version and trying to get it to work on webgl.

    Webgl doesn't support threading and I notice that the replay tasks are managed as threads. Is there an easy way to convert this into a single-threaded model to support webgl?

    Thanks
     
  42. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    HI,
    This should already work without issue on WebGL. All threading code will get disabled when buidling for WebGL via pre processor directives shown below so there should be no issue.

    Code (CSharp):
    1. // Disable threading on web platforms
    2. #if UNITY_WEBGL
    3. #define ULTIMATEREPLAY_NOTHREADING
    4. #endif
    If for some reason WebGL is not working correctly for you then just let me know and we can look into.
     
  43. justinleavesley

    justinleavesley

    Joined:
    Jul 14, 2013
    Posts:
    2
    Ok great!! Will let you know if I hit any problems
     
  44. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Ultimate Replay version 1.1.9 has been submitted to the asset store for review. This version contains:
    • Exposed the 'UpdateState' method of the ReplayManager which allows you to manually update playback and recording where finer control is required. You can also pass a delta time value to this method to update independantly from the Unity time system.
    • Fixed a bug where the initial position and rotation of a replay prefab could become corrupted causing NaN and assignment errors.
     
  45. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    Hello, and this is certainly a great asset for recording movement of objects!

    May I ask whether it is possible to record different methods/functions called at certain frames?

    Is it also possible to record audio clips (sound effect clips to be specific) being played and stopped at certain frames?

    Thank you!
     
  46. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi,
    You can record a method call using ReplayEvents but it will require a little bit of work on your part. Note that there is no built in support for serializing method or delegates so there are some limitations. Here is an example of how you could record a method call:

    Code (CSharp):
    1. class Example : ReplayBehaviour
    2.     {
    3.         // A unique replay event ID used to identity the event data
    4.         byte recordChannel = 128;
    5.  
    6.         // Called for every replay event recorded in the current playback snapshot
    7.         public override void OnReplayEvent(ReplayEvent replayEvent)
    8.         {
    9.             // This callback is fired for every replay event so we need to make sure that the replay ID matches our expected value
    10.             if (replayEvent.eventID == recordChannel)
    11.             {
    12.                 MethodIWantToRecord();
    13.             }
    14.         }
    15.  
    16.         // The method you want to record. Simply call this method during recording and the method call will be recored as a replay event and replayed during playback
    17.         public void MethodIWantToRecord()
    18.         {
    19.             // Make sure the replay manager is recording
    20.             if (IsRecording == true)
    21.             {
    22.                 // Record the method call event in the current snapshot
    23.                 ReplayRecordEvent(recordChannel);
    24.             }
    25.  
    26.             // Do something else
    27.             Debug.Log("Method called");
    28.         }
    29.     }
    For recording audio clips there is a built in 'ReplayAudio' component that is able to record sounds also using replay events. Note that this component does not support playback of audio in reverse.

    Let me know if you have any more questions.
     
  47. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    Great, I understand this. Thank you very much!
     
    scottyboy805 likes this.
  48. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    Hello there,

    I have two issues facing.

    First, I have this .replay file and a ReplayManager object whose Playback End Behaviour = EndPlayback. After the recording ends, this shows up:
    upload_2020-1-16_21-59-15.png

    Second, is it possible to begin playback of two separate .replay files? In other words, after a few moments as the first recording finishes its playback, another recording begins?

    Thank you very much.
     
  49. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    705
    Hi,
    Are you using the latest update (1.1.9) which was released a couple of weeks ago. That update should have fixed the error you are gteeing but if you are using the latest version then we will look into it furhter as it should have been fixed.

    It is not possible to record or replay mutliple instances simultaneously at the moment but I am not sure if thats what you are asking for. If you just want to start recording with a different replay file after playback of another recording has finished then that is possible. You will need to deal with the ReplayFileTarget component directly in order to change the file loaction to save or load.
     
  50. UA_AV

    UA_AV

    Joined:
    Apr 18, 2017
    Posts:
    14
    I am at home as of this typing, so I will check what version I am using and will inform you at the soonest. Is it okay if I send you my scene and related assets as a .unitypackage file via email?

    Does this mean that, with the ReplayManager's "PlayBack End Behaviour" field set to "EndPlayback", the following steps are possible?
    1. Being playback of .replay file #1.
    2. Change the file directory and filename fields of the Replay File Target component to the next .replay file.
    3. Begin playback of .replay file #2.


    As of this typing, my ReplayManager's "Playback End Behaviour" field is set to "StopPlayback", and I wrote some code to check whether ReplayManager's time >= ReplayManager.Target.Duration (because of the above issue I am facing if the "Playback End Behaviour" field is set to "EndPlayback"). However, I would need to call ReplayManager.StopPlayback() method before moving on to the next .replay file, and it would catch the same exception which I sent hours ago.


    Thank you very much.
     
unityunity