Search Unity

  1. Dismiss Notice
  2. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  3. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  4. 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

Getting time of clips on playing alembic tracks

Discussion in 'Formats & External Tools' started by bastianLstrube, Feb 25, 2019.

  1. bastianLstrube

    bastianLstrube

    Joined:
    Feb 15, 2014
    Posts:
    8
    Hi!
    neScreenshot.PNG
    We're in the middle of a VR project that extensively uses alembic files of recorded actors.
    On these we add video textures synced to the alembic files.
    Exactly a year ago we made a prototype using the alembic importer from github (https://github.com/unity3d-jp/AlembicForUnity). Back then it was possible to reference the alembicStreamPlayer component to get the current time of the alembic file to sync a VideoPlayer component. This took a programmer we hired as a consultant about 10 minutes.

    Now however, that seems to be internal and all that is left exposed is the Timeline part.
    We haven't been able to get the information on which clip is playing on alembic tracks, what time they are currently on and what their start and end frame is.

    Problem: Script that listens for currently playing alembic clips on the timeline and syncs a video component on each of those playing alembic game objects.

    Unity_alembicVideoTrouble.PNG

    I'm a tech artist and not familiar enough with programming to find a solution.
    But we haven't managed to find programmers experience with the timeline either. The few we had by tried but couldn't figure it out. Hope there's an easy solution we're not seeing.
    We've recorded a full cast of characters and extras with the expectation that our test with the alembic importer would work again.

    Thanks!
     
  2. vladala

    vladala

    Unity Technologies

    Joined:
    Mar 3, 2017
    Posts:
    94
    Hey,

    Unfortunately we had to make everything internal pending an API review. A proper public API is in the works.
    Until then you can use the following code to get the time from alembic:
    Just add it next to the alembicStreamPlayer, or point to the GameObject that has the alembic
    ///////
    using System.Collections;
    using System.Collections.Generic;
    using System.Reflection;
    using UnityEditor;
    using UnityEngine;
    using UnityEngine.AI;

    [ExecuteInEditMode]
    public class DumpTime : MonoBehaviour
    {
    // Start is called before the first frame update
    void OnEnable()
    {
    var alembicPlayer = gameObject.GetComponent("AlembicStreamPlayer");
    var so = new SerializedObject(alembicPlayer);
    var prop = so.FindProperty("currentTime");
    Debug.Log(prop.floatValue);
    }
    }
    //////
     
  3. bastianLstrube

    bastianLstrube

    Joined:
    Feb 15, 2014
    Posts:
    8
    Hi!

    Late reply, but thank you!
    Video syncs up with alembics.... in editor only.
    The script throws an error when trying to build.

    Assets\_Project\Scripts\AlembicVideoSync.cs(18,22): error CS0246: The type or namespace name 'SerializedObject' could not be found (are you missing a using directive or an assembly reference?)
     
  4. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    The attached files allow to control AlembicStreamPlayer normally.
    • Copy the 2 files inside the proper folder : %Project% \Library\PackageCache\com.unity.formats.alembic@1.0.2\Runtime\Scripts\Importer in windows.
    • then add a AlembicStreamController component on the game object that has your AlembicStreamPlayer
    • reference that from another script and set the time variable to change the current time
    Hope that helps
     

    Attached Files:

  5. rob_unity7

    rob_unity7

    Joined:
    Feb 8, 2019
    Posts:
    37
    Hi, thanks for this. I'm struggling to get this working on WebGL. its not building.

    This is the error I'm getting when I try to build:
    Code (CSharp):
    1. Assets\Scripts\Alembic\AlembicAnimatable.cs(14,17): error CS0246: The type or namespace name 'AlembicStreamController' could not be found (are you missing a using directive or an assembly reference?)
    Any ideas?
     
  6. vladala

    vladala

    Unity Technologies

    Joined:
    Mar 3, 2017
    Posts:
    94
    Hey,

    I can't possible see how this is possible. Alembic uses native plugins and we support only Windows/OSX/Linux standalone targets.
     
  7. Alky123

    Alky123

    Joined:
    Dec 27, 2020
    Posts:
    1
    Hi,

    is there any update for the API? I'm trying to manually control the animation but none of the answers above works for me. I tried to implement the answer from vladala (Feb 25,2019) with minor change - I tried to update the float value of a property on Update() method. The value is changing according to Debug.Log, but I can see no change in the value of field "Time" on Alembic Stream Player component in Editor, which is still 0. And of course my animation is not "playing". When I change the field in editor manually, everything works.

    When I try to copy the files Ben-Kuper attached, I get this error from Unity:

    upload_2020-12-29_16-31-47.png

    The error message translates: "The system cannot find the specified file", which is really weird, because I have just copied the file that is missing.

    I'm using Unity 2020.2.0b2.3094 and Alembic 1.0.7

    Thank you in advance.
     
  8. vladala

    vladala

    Unity Technologies

    Joined:
    Mar 3, 2017
    Posts:
    94
    Alembic does async updates for performance reasons: during the update phase it "asks" for the frame to update, but not block until lateUpdate. You could try calling LateUpdate yourself (dunno about additional side effects) if you want the result during Update
    Alembic 2.0.X has a new function called UpdateImmediately you could try.
     
unityunity