Пример #1
0
        protected virtual void Awake()
        {
            if (main != null)
            {
                if (main != this)
                {
                    return;
                }
            }

            if (!useCrossInput)
            {
                virtualInput = new StandaloneInput();
                Destroy(this);
                return;
            }

            virtualInput = new MobileInput();
            main         = this;
            DontDestroyOnLoad(this);

            InputSource source;

            numSources = 0;
            int i = 0, imax = m_Sources.Length;

            sources = new List <InputSource>(imax);
            for (; i < imax; ++i)
            {
                // Fix gameObject...
                if (m_Sources[i] == null || !m_Sources[i].gameObject.activeInHierarchy)
                {
                    continue;
                }
                source = m_Sources[i] as InputSource;
                if (source != null)
                {
                    if (source.enabled)
                    {
                        if (source.InitInput() == 0)
                        {
                            sources.Add(source);
                            numSources++;
                        }
                    }
                }
            }
            PrintLogOnStartup();
            _waitEof = new WaitForEndOfFrame();
            StartCoroutine(UpdateOnEof());
        }
 void Update()
 {
     if (StandaloneInput.GetKey(KeyCode.UpArrow))
     {
         transform.Translate(new Vector3(0f, 0.1f, 0f));
     }
     if (StandaloneInput.GetKey(KeyCode.DownArrow))
     {
         transform.Translate(new Vector3(0f, -0.1f, 0f));
     }
     if (StandaloneInput.GetKey(KeyCode.LeftArrow))
     {
         transform.Translate(new Vector3(-0.1f, 0f, 0f));
     }
     if (StandaloneInput.GetKey(KeyCode.RightArrow))
     {
         transform.Translate(new Vector3(0.1f, 0f, 0f));
     }
 }
Пример #3
0
    void Awake()
    {
        position = this.transform.position;
        //rotation = Vector2.zero;
        //res_rotation = this.transform.rotation.eulerAngles;

        t_velocity = Vector2.zero;
        r_velocity = Vector2.zero;

        //Obtener controles para ordenador o para moviles
        #if UNITY_ANDROID
        PhoneInputs phoneInputs = this.gameObject.AddComponent <PhoneInputs>();
        inputs = (Inputs)phoneInputs;
        joystick.gameObject.SetActive(true);
        inputs.SetJoystick(joystick, this);
        #else
        joystick.gameObject.SetActive(false);
        StandaloneInput standaloneInput = this.gameObject.AddComponent <StandaloneInput>();
        inputs = (Inputs)standaloneInput;
        #endif
    }