Inheritance: MonoBehaviour
Example #1
0
    protected override void OnInit()
    {
        base.OnInit();
        mSprite   = (mWidget as UISprite);
        mSprite2D = (mWidget as UI2DSprite);
        if (mSprite != null)
        {
            mNormalSprite = mSprite.spriteName;
        }
        if (mSprite2D != null)
        {
            mNormalSprite2D = mSprite2D.sprite2D;
        }

        //add a sound
        UIPlaySound playsound = transform.GetComponent <UIPlaySound>();

        if (playsound == null)
        {
            playsound = transform.gameObject.AddComponent <UIPlaySound>();
        }
        if (playsound != null)
        {
            playsound.audioClip = Resources.Load <AudioClip>("pre/sound/Plastic_Click_1");
        }
    }
Example #2
0
 private static void SetUIPlaySound(XmlElement el, UIPlaySound comp)
 {
     el.SetAttribute("audioClip", comp.audioClip.ToString());
     el.SetAttribute("audioClip", comp.trigger.ToString());
     el.SetAttribute("volume", comp.volume.ToString());
     el.SetAttribute("pitch", comp.pitch.ToString());
 }
 void Awake()
 {
     if (mToggle == null) mToggle = GetComponent<UIToggle>();
     if (mToggleObjects == null) mToggleObjects = GetComponent<UIToggledObjects>();
     if (mPlaySound == null) mPlaySound = GetComponent<UIPlaySound>();
     if (mBtnActivate == null) mBtnActivate = GetComponent<UIButtonActivate>();
 }
Example #4
0
 void Start()
 {
     LoadConfig();
     InitInput();
     anim        = this.character.GetComponent <SkeletonAnimation> ();
     anim_letter = this.battle_letter.GetComponent <Animation> ();
     audio       = this.character.GetComponent <UIPlaySound> ();
 }
Example #5
0
        public MatchMsgBtn(GameObject inBtn, MatchMsg inMsg)
        {
            btn = inBtn;
            msg = inMsg;

            valid   = true;
            timeCnt = 0;

            m_btnScale = btn.GetComponent <UIButtonScale>();
            m_btnSound = btn.GetComponent <UIPlaySound>();
        }
Example #6
0
 static public int get_volume(IntPtr l)
 {
     try {
         UIPlaySound self = (UIPlaySound)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.volume);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #7
0
 static public int Play(IntPtr l)
 {
     try {
         UIPlaySound self = (UIPlaySound)checkSelf(l);
         self.Play();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #8
0
 static public int get_trigger(IntPtr l)
 {
     try {
         UIPlaySound self = (UIPlaySound)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.trigger);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #9
0
 void Start()
 {
     UIEventListener[] btns = transform.GetComponentsInChildren<UIEventListener>();
     buttons = new UIEventListener[btns.Length];
     for (short i = 0; i < btns.Length; ++i)
     {
         buttons[i] = btns[i];
         buttons[i].onClick = onClick;
     }
     retractBtn = buttons[1].GetComponent<UIButton>();
     clickSound = transform.GetComponent<UIPlaySound>();
 }
 void Start()
 {
     //Get components from the scene at init.
     //Get the audio from the background, which is the slide sound.
     GameObject background = GameObject.FindWithTag("Background");
     slideSound = background.GetComponent<UIPlaySound>();
     //Get the scroll bar from the race scroll element.
     GameObject raceScrollBarObject = GameObject.FindWithTag("RaceScrollBar");
     raceScrollBar = raceScrollBarObject.GetComponent<UIScrollBar>();
     //Get the scroll bar from the ship scroll element.
     GameObject shipScrollBarObject = GameObject.FindWithTag("ShipScrollBar");
     shipScrollBar = shipScrollBarObject.GetComponent<UIScrollBar>();
 }
Example #11
0
        void Start()
        {
            for (short i = 0; i < buttons.Length; ++i)
                buttons[i].onClick = onClick;

            for (short i = 4; i < 6; ++i)
                buttons[i].GetComponent<UISprite>().alpha = 0;

            Global.gameScene = GameScenes.WELCOME;
            Global.setSceneOld(GameScenes.WELCOME);

            clickSound = transform.GetComponent<UIPlaySound>();
        }
Example #12
0
        IEnumerator LoadAudioClip(string sound_path, UIPlaySound play_sound)
        {
            AssetResource asset_res = new AssetResource();

            yield return(ResourceLoader.Instance.load_asset(sound_path, typeof(AudioClip), asset_res));

            var audio_clip = asset_res.asset_ as AudioClip;

            if (play_sound != null && audio_clip != null)
            {
                play_sound.audioClip = audio_clip;
                play_sound.ForceClick();// 需要主动调用一次
            }
        }
Example #13
0
    void Awake()
    {
        for (short i = 0; i < buttons.Length; ++i)
            buttons[i].onClick = onClick;

        backs = new UISprite[6];
        for (short i = 0; i < 6; ++i)
            backs[i] = buttons[i].transform.FindChild("back").GetComponent<UISprite>();

        nameInput = transform.FindChild("myName").GetComponent<UIInput>();
        audioButton = transform.FindChild("audioOn").GetComponent<UIToggle>();

        clickSound = transform.GetComponent<UIPlaySound>();
    }
Example #14
0
 static public int set_volume(IntPtr l)
 {
     try {
         UIPlaySound   self = (UIPlaySound)checkSelf(l);
         System.Single v;
         checkType(l, 2, out v);
         self.volume = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #15
0
 static public int set_trigger(IntPtr l)
 {
     try {
         UIPlaySound         self = (UIPlaySound)checkSelf(l);
         UIPlaySound.Trigger v;
         checkEnum(l, 2, out v);
         self.trigger = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #16
0
 static public int set_audioClip(IntPtr l)
 {
     try {
         UIPlaySound           self = (UIPlaySound)checkSelf(l);
         UnityEngine.AudioClip v;
         checkType(l, 2, out v);
         self.audioClip = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #17
0
    void Start()
    {
        //Get components from the scene at init.
        //Get the audio from the background, which is the slide sound.
        GameObject background = GameObject.FindWithTag("Background");

        slideSound = background.GetComponent <UIPlaySound>();
        //Get the scroll bar from the race scroll element.
        GameObject raceScrollBarObject = GameObject.FindWithTag("RaceScrollBar");

        raceScrollBar = raceScrollBarObject.GetComponent <UIScrollBar>();
        //Get the scroll bar from the ship scroll element.
        GameObject shipScrollBarObject = GameObject.FindWithTag("ShipScrollBar");

        shipScrollBar = shipScrollBarObject.GetComponent <UIScrollBar>();
    }
Example #18
0
    private void scan()
    {
        Result result = reader.Decode(temps, cameraTexture.height, cameraTexture.width);

        if (result != null)
        {
            DialogUtil.tip(result.Text);
            UIPlaySound sound = gameObject.GetComponent <UIPlaySound>();
            sound.Play();
            cameraTexture.Stop();
            if (callBack != null)
            {
                callBack.Execute();
            }
        }
    }
Example #19
0
    private void CheckUIButtonSoundInGo(GameObject go)
    {
        _goCount++;
        UIButton[] uiButtons = go.GetComponents <UIButton>();
        if (uiButtons != null && uiButtons.Length > 0)
        {
            _hitCount++;
            _resultList.Add(go);
            string path = GetHierarchyWithRoot(go);
            if (uiButtons.Length > 1)
            {
                Debug.LogError(string.Format("{0} 存在多于一个UIButton组件,请检查", path));
            }

            UIPlaySound[] uiPlaySounds = go.GetComponents <UIPlaySound>();
            UIPlaySound   playSound    = null;
            if (uiPlaySounds != null && uiPlaySounds.Length > 0)
            {
                playSound = uiPlaySounds[0];

                //删除冗余的UIPlaySound组件
                if (uiPlaySounds.Length > 1)
                {
                    Debug.LogError(string.Format("{0} 存在多于一个UIPlaySound组件,已清除", path));
                    for (var i = 1; i < uiPlaySounds.Length; i++)
                    {
                        GameObject.DestroyImmediate(uiPlaySounds[i], true);
                    }
                }
            }

            if (playSound == null)
            {
                playSound = go.AddComponent <UIPlaySound>();
            }

            playSound.audioClip = _buttonAudioClip;
            playSound.trigger   = UIPlaySound.Trigger.OnClick;
        }

        //递归遍历子节点
        foreach (Transform child in go.transform)
        {
            CheckUIButtonSoundInGo(child.gameObject);
        }
    }
    public static int Play(IntPtr l)
    {
        int result;

        try
        {
            UIPlaySound uIPlaySound = (UIPlaySound)LuaObject.checkSelf(l);
            uIPlaySound.Play();
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    public static int get_audioClip(IntPtr l)
    {
        int result;

        try
        {
            UIPlaySound uIPlaySound = (UIPlaySound)LuaObject.checkSelf(l);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, uIPlaySound.audioClip);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    public static int get_trigger(IntPtr l)
    {
        int result;

        try
        {
            UIPlaySound uIPlaySound = (UIPlaySound)LuaObject.checkSelf(l);
            LuaObject.pushValue(l, true);
            LuaObject.pushEnum(l, (int)uIPlaySound.trigger);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    private void Select(UILabel lbl, bool instant)
    {
        Highlight(lbl, instant);
        UIEventListener component = lbl.gameObject.GetComponent <UIEventListener>();

        value = (component.parameter as string);
        UIPlaySound[] components = GetComponents <UIPlaySound>();
        int           i          = 0;

        for (int num = components.Length; i < num; i++)
        {
            UIPlaySound uIPlaySound = components[i];
            if (uIPlaySound.trigger == UIPlaySound.Trigger.OnClick)
            {
                NGUITools.PlaySound(uIPlaySound.audioClip, uIPlaySound.volume, 1f);
            }
        }
    }
    public static int set_pitch(IntPtr l)
    {
        int result;

        try
        {
            UIPlaySound uIPlaySound = (UIPlaySound)LuaObject.checkSelf(l);
            float       pitch;
            LuaObject.checkType(l, 2, out pitch);
            uIPlaySound.pitch = pitch;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    /// <summary>
    /// Event function triggered when the drop-down list item gets clicked on.
    /// </summary>

    protected virtual void OnItemClick(GameObject go)
    {
        Select(go.GetComponent <UILabel>(), true);

        UIEventListener listener = go.GetComponent <UIEventListener>();

        value = listener.parameter as string;
        UIPlaySound[] sounds = GetComponents <UIPlaySound>();

        for (int i = 0, imax = sounds.Length; i < imax; ++i)
        {
            UIPlaySound snd = sounds[i];
            if (snd.trigger == UIPlaySound.Trigger.OnClick)
            {
                NGUITools.PlaySound(snd.audioClip, snd.volume, 1f);
            }
        }
        CloseSelf();
    }
    public static int set_trigger(IntPtr l)
    {
        int result;

        try
        {
            UIPlaySound         uIPlaySound = (UIPlaySound)LuaObject.checkSelf(l);
            UIPlaySound.Trigger trigger;
            LuaObject.checkEnum <UIPlaySound.Trigger>(l, 2, out trigger);
            uIPlaySound.trigger = trigger;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    public static int set_audioClip(IntPtr l)
    {
        int result;

        try
        {
            UIPlaySound uIPlaySound = (UIPlaySound)LuaObject.checkSelf(l);
            AudioClip   audioClip;
            LuaObject.checkType <AudioClip>(l, 2, out audioClip);
            uIPlaySound.audioClip = audioClip;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    void Start()
    {
        //Get components from the scene at init.
        //Get the audio from the quit button, the slide onto quit audio
        GameObject quitButton = GameObject.FindWithTag("QuitButton");
        quitSlideSound = quitButton.GetComponent<UIPlaySound>();
        
        //Get the audio from the start button, the default select audio
        GameObject startButton = GameObject.FindWithTag("StartButton");
        slideSound = startButton.GetComponent<UIPlaySound>();

        //Get the vertical scroll bar.
        GameObject verticalScrollBarObject = GameObject.FindWithTag("MainMenuScrollBar");
        verticalScrollBar = verticalScrollBarObject.gameObject.GetComponent<UIScrollBar>();

        //Get the audio from the background, which happens to be the select sound
        GameObject background = GameObject.FindWithTag("Background");
        selectSound = background.GetComponent<UIPlaySound>();
    }
    IEnumerator DestroyGameObject()
    {
        yield return(new WaitForSeconds(DestroyTime));

        if (destroyAudio != null)
        {
            UIPlaySound us = gameObject.AddComponent <UIPlaySound>();
            us.audioClip = destroyAudio;
            us.Play();
        }
        if (isSetHide)
        {
            gameObject.SetActive(false);
        }
        else
        {
            Destroy(gameObject);
        }
    }
 private void OnItemPress(GameObject go, bool isPressed)
 {
     if (isPressed)
     {
         Select(go.GetComponent <UILabel>(), true);
         UIEventListener component = go.GetComponent <UIEventListener>();
         value = (component.parameter as string);
         UIPlaySound[] components = this.GetComponents <UIPlaySound>();
         int           i          = 0;
         for (int num = components.Length; i < num; i++)
         {
             UIPlaySound uIPlaySound = components[i];
             if (uIPlaySound.trigger == UIPlaySound.Trigger.OnClick)
             {
                 NGUITools.PlaySound(uIPlaySound.audioClip, uIPlaySound.volume, 1f);
             }
         }
         CloseSelf();
     }
 }
Example #31
0
    void Start()
    {
        //Get the audio from the background, which is the slide sound
        GameObject background = GameObject.FindWithTag("Background");
        slideSound = background.GetComponent<UIPlaySound>();

        //Get the START MATCH label.
        startMatch = GameObject.FindWithTag("StartMatch");
        //Get the greyed out label
        startMatchGreyed = GameObject.FindWithTag("StartMatchGreyed");

        //Ensure the greyed out label is displayed at start
        startMatch.SetActive(false);
        startMatchGreyed.SetActive(true);

        //Set the number of players
        numberOfPlayers = 9;
        //Ready count should be the number of players
        notReadyCount = numberOfPlayers;
    }
Example #32
0
    // Token: 0x0600311D RID: 12573 RVA: 0x000F0D4C File Offset: 0x000EF14C
    private void Select(UILabel lbl, bool instant)
    {
        this.Highlight(lbl, instant);
        UIEventListener component = lbl.gameObject.GetComponent <UIEventListener>();

        this.value = (component.parameter as string);
        UIPlaySound[] components = base.GetComponents <UIPlaySound>();
        int           i          = 0;
        int           num        = components.Length;

        while (i < num)
        {
            UIPlaySound uiplaySound = components[i];
            if (uiplaySound.trigger == UIPlaySound.Trigger.OnClick)
            {
                NGUITools.PlaySound(uiplaySound.audioClip, uiplaySound.volume, 1f);
            }
            i++;
        }
    }
Example #33
0
    /// <summary>
    /// Select the specified label.
    /// </summary>

    void Select(UILabel lbl, bool instant)
    {
        Highlight(lbl, instant);

        UIEventListener listener = lbl.gameObject.GetComponent <UIEventListener>();

        value = listener.parameter as string;

        UIPlaySound[] sounds = GetComponents <UIPlaySound>();

        for (int i = 0, imax = sounds.Length; i < imax; ++i)
        {
            UIPlaySound snd = sounds[i];

            if (snd.trigger == UIPlaySound.Trigger.OnClick)
            {
                NGUITools.PlaySound(snd.audioClip, snd.volume, 1f);
            }
        }
    }
Example #34
0
    void Start()
    {
        //Get the audio from the background, which is the slide sound
        GameObject background = GameObject.FindWithTag("Background");

        slideSound = background.GetComponent <UIPlaySound>();

        //Get the SELECT [ENTER] label.
        selectEnter = GameObject.FindWithTag("SelectEnter");
        //Get the greyed out label
        selectEnterGreyed = GameObject.FindWithTag("SelectEnterGreyed");

        //Ensure the greyed out label is displayed at start
        selectEnter.SetActive(false);
        selectEnterGreyed.SetActive(true);

        //Get the Mission Info Boxes
        aesopInfoBox    = GameObject.FindWithTag("AesopInfoBox");
        fourcroyInfoBox = GameObject.FindWithTag("FourcroyInfoBox");
        herronsInfoBox  = GameObject.FindWithTag("HerronsInfoBox");
        santaroInfoBox  = GameObject.FindWithTag("SantaroInfoBox");

        //Get the Mission Selection Spheres.
        aesop    = GameObject.FindWithTag("Aesop");
        fourcroy = GameObject.FindWithTag("Fourcroy");
        herrons  = GameObject.FindWithTag("Herrons");
        santaro  = GameObject.FindWithTag("Santaro");

        //Get the starting transform scales of the Mission Spheres
        aesopScale    = aesop.transform.localScale;
        fourcroyScale = fourcroy.transform.localScale;
        herronsScale  = herrons.transform.localScale;
        santaroScale  = santaro.transform.localScale;


        //Hide the mission text boxes
        HideAesopMissionText();
        HideFourcroyMissionText();
        HideHerronsMissionText();
        HideSantaroMissionText();
    }
Example #35
0
    void Start()
    {
        //Get the audio from the background, which is the slide sound
        GameObject background = GameObject.FindWithTag("Background");

        slideSound = background.GetComponent <UIPlaySound>();

        //Get the START MATCH label.
        startMatch = GameObject.FindWithTag("StartMatch");
        //Get the greyed out label
        startMatchGreyed = GameObject.FindWithTag("StartMatchGreyed");

        //Ensure the greyed out label is displayed at start
        startMatch.SetActive(false);
        startMatchGreyed.SetActive(true);

        //Set the number of players
        numberOfPlayers = 9;
        //Ready count should be the number of players
        notReadyCount = numberOfPlayers;
    }
Example #36
0
    // Token: 0x0600029F RID: 671 RVA: 0x0001A58C File Offset: 0x0001878C
    protected virtual void OnItemClick(GameObject go)
    {
        this.Select(go.GetComponent <UILabel>(), true);
        UIEventListener component = go.GetComponent <UIEventListener>();

        this.value = (component.parameter as string);
        UIPlaySound[] components = base.GetComponents <UIPlaySound>();
        int           i          = 0;
        int           num        = components.Length;

        while (i < num)
        {
            UIPlaySound uiplaySound = components[i];
            if (uiplaySound.trigger == UIPlaySound.Trigger.OnClick)
            {
                NGUITools.PlaySound(uiplaySound.audioClip, uiplaySound.volume, 1f);
            }
            i++;
        }
        this.CloseSelf();
    }
    void Start()
    {
        //Get the audio from the background, which is the slide sound
        GameObject background = GameObject.FindWithTag("Background");
        slideSound = background.GetComponent<UIPlaySound>();

        //Get the SELECT [ENTER] label.
        selectEnter = GameObject.FindWithTag("SelectEnter");
        //Get the greyed out label
        selectEnterGreyed = GameObject.FindWithTag("SelectEnterGreyed");

        //Ensure the greyed out label is displayed at start
        selectEnter.SetActive(false);
        selectEnterGreyed.SetActive(true);

        //Get the Mission Info Boxes
        aesopInfoBox = GameObject.FindWithTag("AesopInfoBox");
        fourcroyInfoBox = GameObject.FindWithTag("FourcroyInfoBox");
        herronsInfoBox = GameObject.FindWithTag("HerronsInfoBox");
        santaroInfoBox = GameObject.FindWithTag("SantaroInfoBox");

        //Get the Mission Selection Spheres.
        aesop = GameObject.FindWithTag("Aesop");
        fourcroy = GameObject.FindWithTag("Fourcroy");
        herrons = GameObject.FindWithTag("Herrons");
        santaro = GameObject.FindWithTag("Santaro");

        //Get the starting transform scales of the Mission Spheres
        aesopScale = aesop.transform.localScale;
        fourcroyScale = fourcroy.transform.localScale;
        herronsScale = herrons.transform.localScale;
        santaroScale = santaro.transform.localScale;


        //Hide the mission text boxes
        HideAesopMissionText();
        HideFourcroyMissionText();
        HideHerronsMissionText();
        HideSantaroMissionText();
    }
Example #38
0
 private void OnItemPress(GameObject go, Boolean isPressed)
 {
     if (isPressed)
     {
         this.Select(go.GetComponent <UILabel>(), true);
         UIEventListener component = go.GetComponent <UIEventListener>();
         this.value = (component.parameter as String);
         UIPlaySound[] components = base.GetComponents <UIPlaySound>();
         Int32         i          = 0;
         Int32         num        = (Int32)components.Length;
         while (i < num)
         {
             UIPlaySound uiplaySound = components[i];
             if (uiplaySound.trigger == UIPlaySound.Trigger.OnClick)
             {
                 NGUITools.PlaySound(uiplaySound.audioClip, uiplaySound.volume, 1f);
             }
             i++;
         }
         this.CloseSelf();
     }
 }
 void Awake()
 {
     m_sound = GetComponent<UIPlaySound>();
 }