Использование скрипта в другом скрипте c # unity - PullRequest
0 голосов
/ 28 марта 2019

У меня есть вопрос, у меня есть код единства с vuforia, в котором я выполняю видеоповтор, моя проблема в том, что я хочу использовать скрипт внутри другого, и я использую общедоступный GameObject CamaraObject, чтобы иметь возможность использовать его в другом скриптено он не распознает меня в момент отправки вызова, не могли бы вы сказать мне, в чем я не прав или я что-то упустил ?, вот мой код:

'' 'C # MainManager.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;

public class MainManager : MonoBehaviour
{

public GameObject[] videoPlayer;


    public GameObject playButton;
    public GameObject stopButton;
    public GameObject nextButton;
    public GameObject prevButton;
    public GameObject muteButton;
    public GameObject soundButton;


    int CurrentPlayer = 0;
    // Start is called before the first frame update
    void Start()
    {
        DisableAll();
    }

    // Update is called once per frame
    void Update()
    {

    }

    public void Play()
    {
        videoPlayer[CurrentPlayer].SetActive(true);
        videoPlayer[CurrentPlayer].GetComponent<VideoPlayer>().Play();
    }

    public void Pause()
    {
        videoPlayer[CurrentPlayer].GetComponent<VideoPlayer>().Pause();
    }

    public void Mute()
    {
        videoPlayer[CurrentPlayer].GetComponent<AudioSource>().mute=true;
    }

    public void Sound()
    {
        videoPlayer[CurrentPlayer].GetComponent<AudioSource>().mute = false;
    }

    public void Next()
    {
        CurrentPlayer++;
        Play();
    }

    public void Previous()
    {
        CurrentPlayer--;
        Play();
    }

    public void DisableAll()
    {
        foreach (var i in videoPlayer)
        {
            i.SetActive(false);
        }
    }
}

'' 'C # DefaultTrackableEventHandler.cs

using UnityEngine;
using Vuforia;

    protected TrackableBehaviour mTrackableBehaviour;
    protected TrackableBehaviour.Status m_PreviousStatus;
    protected TrackableBehaviour.Status m_NewStatus;
    #endregion // PROTECTED_MEMBER_VARIABLES
    public GameObject CamaraObject;


    protected virtual void OnTrackingFound()
    {
        var rendererComponents = GetComponentsInChildren<Renderer>(true);
        var colliderComponents = GetComponentsInChildren<Collider>(true);
        var canvasComponents = GetComponentsInChildren<Canvas>(true);

        // Enable rendering:
        foreach (var component in rendererComponents)
            component.enabled = true;

        // Enable colliders:
        foreach (var component in colliderComponents)
            component.enabled = true;

        // Enable canvas':
        foreach (var component in canvasComponents)
            component.enabled = true;

    CamaraObject.GetComponent<MainManager>().Play();
    }

мне нужно вызвать этот MainManager на строку CamaraObject.GetComponent. (). Play (), но он сказал: отсутствует директива using или ссылка на сборку

...