Exemplo n.º 1
0
    public void Init()
    {
        AudioCaptions = new TextAsset("");

        cover = transform.Find("Cover").gameObject;

        foreach (Canvas c in GetComponentsInChildren <Canvas>())
        {
            if (c.gameObject.name == "CaptionsCanvas")
            {
                CaptionsCanvas = c.gameObject;
            }
        }
        if (CaptionsCanvas == null)
        {
            Debug.LogError("no captions canvas");
        }

        foreach (TextMeshProUGUI tm in GetComponentsInChildren <TextMeshProUGUI>())
        {
            if (tm.name == "Title noedit")
            {
                Title = tm;
            }
        }
        foreach (Image i in GetComponentsInChildren <Image>())
        {
            if (i.name == "Background_Image")
            {
                BgPhoto = i;
            }
        }
        foreach (AudioSource srcObj in GetComponentsInChildren <AudioSource>())
        {
            if (srcObj.name == "AudioSourceAndTools")
            {
                src = srcObj;
            }
        }
        foreach (UIB_AudioPlayerTools tools in GetComponentsInChildren <UIB_AudioPlayerTools>())
        {
            if (tools.name == "AudioSourceAndTools")
            {
                this.Tools = tools;
            }
        }


        foreach (Button b in GetComponentsInChildren <Button>())
        {
            if (b.name == "Captions_Button")
            {
                CaptionsToggle = b.gameObject;
                b.onClick.RemoveAllListeners();
                b.GetComponentInChildren <TextMeshProUGUI>().faceColor = new Color32(255, 255, 255, 255);

                b.onClick.AddListener(delegate
                {
                    CaptionsShowing = !CaptionsShowing;

                    CaptionsCanvas.GetComponentInChildren <TextMeshProUGUI>().enabled = CaptionsShowing;

                    if (CaptionsCanvas.GetComponentInChildren <TextMeshProUGUI>().enabled)
                    {
                        b.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(200, 197, 43, 255);
                    }
                    else
                    {
                        b.GetComponentInChildren <TextMeshProUGUI>().color = new Color32(255, 255, 255, 255);
                    }
                });

                //  b.onClick.Invoke();
            }
        }

        CaptionsToggle.GetComponentInChildren <TextMeshProUGUI>().enabled = hasCaptions;
        CaptionsToggle.GetComponent <Button>().enabled = hasCaptions;

        GetComponent <AspectRatioFitter>().enabled = false;
        GetComponent <AspectRatioFitter>().enabled = true;
        StartCoroutine(GetComponent <UIB_Page>().ResetUAP(true));
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     tools = GameObject.Find("AudioSourceAndTools").GetComponent <UIB_AudioPlayerTools>();
 }