Esempio n. 1
0
  IEnumerator Start()
  {
    //  Preemptively load clips.
    HarmonyRenderer renderer = GetComponent<HarmonyRenderer>();
    if ( (renderer == null) || (renderer.clipNames == null) )
      yield break;

    //  Preemptively load clip.
    renderer.LoadClipIndex(0 /* first clip */);

    //  Wait for audio if necessary.
    HarmonyAudio audio = gameObject.GetComponent<HarmonyAudio>();
    if ( audio != null )
    {
      yield return StartCoroutine(audio.WaitForDownloads());
    }

    HarmonyAnimation animation = gameObject.GetComponent<HarmonyAnimation>();
    if ( animation != null )
    {
      HarmonyAnimation.CallbackEvents callbacks = new HarmonyAnimation.CallbackEvents();

      //  Trigger a callback at frame 10 of animation.
      callbacks.AddCallbackAtFrame( 10.0f, CallbackMethod1 );

      //  Trigget a callback at end of animation.
      callbacks.AddCallbackAtEnd( CallbackMethod2 );

      //  Loop animation indefinitely.
      animation.LoopAnimation( frameRate, 0 /* first clip */, 1.0f /*first frame*/, false /*forward*/, callbacks );
    }
  }
Esempio n. 2
0
    void postStart()
    {
        HarmonyRenderer renderer = GetComponent <HarmonyRenderer>();

        //  Preemptively load clip.
        renderer.LoadClipIndex(0 /* first clip */);

        HarmonyAnimation animation = gameObject.GetComponent <HarmonyAnimation>();

        if (animation != null)
        {
            HarmonyAnimation.CallbackEvents callbacks = new HarmonyAnimation.CallbackEvents();

            //  Trigger a callback at frame 10 of animation.
            callbacks.AddCallbackAtFrame(10.0f, CallbackMethod1);

            //  Trigget a callback at end of animation.
            callbacks.AddCallbackAtEnd(CallbackMethod2);

            //  Loop animation indefinitely.
            animation.LoopAnimation(frameRate, 0 /* first clip */, 1.0f /*first frame*/, false /*forward*/, callbacks);
        }
        renderer.readyToRender = true;
    }