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

Getting time of clips on playing alembic tracks

Discussion in '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:
    73
    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:
    73
    Hey,

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