Forum rules - please read before posting.

Animated Gif on menu remains disabled on prefab menu is reenabled

Hello, everyone!

I use Old Moat's Animated Gif Player in my project and Adventure Creator 1.72.2. Nothing strange happens when I run a gif on a Scene's object, but if it's attached to a prefab used in a AC Menu, this happens:

https://www.mediafire.com/view/4c3patb52dxw5ha/bustedprefabgif.png/file

I tried everything I could think of to reenable the gif via script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using OldMoatGames;

public class PrefabGifManager : MonoBehaviour
{
public GameObject WholeThing;
public RawImage rawImage;
private readonly string thename = "AnimatedGIFPlayerExampe 1.gif";
public AnimatedGifPlayer player;

public void ResetGif()
{
    // Init the GIF player
    WholeThing.SetActive(true);
    rawImage.gameObject.SetActive(true);
    player.gameObject.SetActive(true);
    rawImage.enabled = true;
    player.enabled = true;
    Debug.Log("Approaching Player.Init()");
    Debug.Log("Approaching Player.Update()");
    player.Update();
    player.Init();
    Debug.Log("Starting ResetGif()");
    player.FileName = thename;
    Debug.Log("Approaching Player.Pause()");
    player.Pause();
    Debug.Log("Okay, now we play it...");
    player.Play();
    Debug.Log("PrefabGifManager.ResetGif() was run. Yay!");

But no combination of these actions work.

Manually resetting the file assigned to the Gif Player in the inspector is the closest thing to a fix I have found:

https://www.mediafire.com/view/tm7rzj2l3eetnmz/bustedprefabgif02.png/file

https://www.mediafire.com/view/p2z3gtca7ysrx25/bustedprefabgif03.png/file

Are there any possibilities I've overlooked?

Thanks always,
Codeprincess

Comments

  • The Debug.Log statements are appearing as expected, I take it.

    When are you calling your ResetGif function? If that too is on the UI prefab, you should be able to use OnEnable.

    Unless the RawImage involved is connected to an AC Graphic Element, then AC won't be interfering with it other than disabling the whole Canvas when the menu is turned off.

    Though, if the Menu it's attached to pauses the game, it's possible that the Gif Player isn't equipped (or needs modifying) to work when the Time.timeScale value is zero.

  • Okay, It's on the UI prefab, so I should use OnEnable and the ActionList runs in the background, so it looks like I'll need to figure out how to re-initialize the gif via script.

    Thank you, Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.