Beispiel #1
0
 public static CSVHelper Instance()
 {
     if (instance == null)
     {
         container = new GameObject("CSVHelper");
         instance  = container.AddComponent <CSVHelper>();
     }
     return(instance);
 }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     //0.初始化DOTween动画组件
     DG.Tweening.DOTween.Init(true, true, DG.Tweening.LogBehaviour.ErrorsOnly).SetCapacity(200, 10);
     //1.读取Excel动画配置表
     CSVHelper.Instance().ReadCSVFile("uiAnimationConfig", (table) => {
         Debug.Log("读取动画配置表成功!");
     });
     //2.给按钮添加点击事件监听
     GetComponent <Button>().onClick.AddListener(OnButtonClick);
 }
        // Use this for initialization
        void Start()
        {
            if (null == m_imgComponent)
            {
                return;
            }
            m_imgComponent.material = new Material(Shader.Find("UI/ImageEffectShader"));
            //m_init = true;
            EventTriggerListener.Get(gameObject).onDown = OnBtnDowm;
            EventTriggerListener.Get(gameObject).onUp   = OnBtnUp;
            CSVTable table = CSVHelper.Instance().SelectFrom("uiAnimationConfig");

            if (null != table)
            {
                string prefix = "";
                switch (btnType)
                {
                case eBtnAnimationType.small:
                    prefix = "small";
                    break;

                case eBtnAnimationType.medium:
                    prefix = "medium";
                    break;

                case eBtnAnimationType.big:
                    prefix = "big";
                    break;

                default:
                    break;
                }

                if (table.ContainsKey(prefix + "ButtonDownStep1"))
                {
                    m_bIfDownStep1 = true;
                    timeDown       = float.Parse(table[prefix + "ButtonDownStep1"]["time"]);
                    scaleDown      = float.Parse(table[prefix + "ButtonDownStep1"]["scale"]);
                    alphaDown      = float.Parse(table[prefix + "ButtonDownStep1"]["alpha"]);
                    timeDownStep1  = float.Parse(table[prefix + "ButtonDownEnd"]["time"]);
                    scaleDownStep1 = float.Parse(table[prefix + "ButtonDownEnd"]["scale"]);
                    alphaDownStep1 = float.Parse(table[prefix + "ButtonDownEnd"]["alpha"]);
                }
                else
                {
                    timeDown  = float.Parse(table[prefix + "ButtonDownEnd"]["time"]);
                    scaleDown = float.Parse(table[prefix + "ButtonDownEnd"]["scale"]);
                    alphaDown = float.Parse(table[prefix + "ButtonDownEnd"]["alpha"]);
                }

                if (table.ContainsKey(prefix + "ButtonReleaseStep1"))
                {
                    //Debug.Log(table["smallButtonReleaseStep1"]["time"]);
                    m_bIfUpStep1 = true;
                    timeUp       = float.Parse(table[prefix + "ButtonReleaseStep1"]["time"]);
                    scaleUp      = float.Parse(table[prefix + "ButtonReleaseStep1"]["scale"]);
                    alphaUp      = float.Parse(table[prefix + "ButtonReleaseStep1"]["alpha"]);
                    timeUpStep1  = float.Parse(table[prefix + "ButtonReleaseEnd"]["time"]);
                    scaleUpStep1 = float.Parse(table[prefix + "ButtonReleaseEnd"]["scale"]);
                    alphaUpStep1 = float.Parse(table[prefix + "ButtonReleaseEnd"]["alpha"]);
                }
                else
                {
                    timeUp  = float.Parse(table[prefix + "ButtonReleaseEnd"]["time"]);
                    scaleUp = float.Parse(table[prefix + "ButtonReleaseEnd"]["scale"]);
                    alphaUp = float.Parse(table[prefix + "ButtonReleaseEnd"]["alpha"]);
                }
            }
        }
        private void Start()
        {
            CSVTable table;            //配置表

            table = CSVHelper.Instance().SelectFrom("uiAnimationConfig");
            if (null != table)
            {
                string prefix = "";                //窗口大小前缀
                switch (windowType)
                {
                case WindowAnimationType.small:
                    prefix = "small";
                    break;

                case WindowAnimationType.medium:
                    prefix = "medium";
                    break;

                case WindowAnimationType.big:
                    prefix = "big";
                    break;

                default:
                    break;
                }
                //Debug.Log(prefix + "WindowOpenStart");
                //初始化值
                alphaInit = float.Parse(table[prefix + "WindowOpenStart"]["alpha"]);

                scaleInit = float.Parse(table[prefix + "WindowOpenStart"]["scale"]);
                if (table.ContainsKey(prefix + "WindowOpenStep1"))
                {
                    m_bIfOpenStep1 = true;
                    timeOpen       = float.Parse(table[prefix + "WindowOpenStep1"]["time"]);
                    scaleOpen      = float.Parse(table[prefix + "WindowOpenStep1"]["scale"]);
                    alphaOpen      = float.Parse(table[prefix + "WindowOpenStep1"]["alpha"]);
                    alphaOpenStep1 = float.Parse(table[prefix + "WindowOpenEnd"]["alpha"]);
                    timeOpenStep1  = float.Parse(table[prefix + "WindowOpenEnd"]["time"]);
                    scaleOpenStep1 = float.Parse(table[prefix + "WindowOpenEnd"]["scale"]);
                }
                else
                {
                    timeOpen  = float.Parse(table[prefix + "WindowOpenEnd"]["time"]);
                    scaleOpen = float.Parse(table[prefix + "WindowOpenEnd"]["scale"]);
                    alphaOpen = float.Parse(table[prefix + "WindowOpenEnd"]["alpha"]);
                }

                if (table.ContainsKey(prefix + "WindowCloseStep1"))
                {
                    //Debug.Log(table["smallWindowCloseStep1"]["time"]);
                    m_bIfCloseStep1 = true;
                    timeClose       = float.Parse(table[prefix + "WindowCloseStep1"]["time"]);
                    scaleClose      = float.Parse(table[prefix + "WindowCloseStep1"]["scale"]);
                    alphaClose      = float.Parse(table[prefix + "WindowCloseStep1"]["alpha"]);
                    alphaCloseStep1 = float.Parse(table[prefix + "WindowCloseEnd"]["alpha"]);
                    timeCloseStep1  = float.Parse(table[prefix + "WindowCloseEnd"]["time"]);
                    scaleCloseStep1 = float.Parse(table[prefix + "WindowCloseEnd"]["scale"]);
                }
                else
                {
                    timeClose  = float.Parse(table[prefix + "WindowCloseEnd"]["time"]);
                    scaleClose = float.Parse(table[prefix + "WindowCloseEnd"]["scale"]);
                    alphaClose = float.Parse(table[prefix + "WindowCloseEnd"]["alpha"]);
                }
                //Debug.Log(gameObject.name + "=>prefix:"+ prefix + "  >>>  " + "timeOpen:" + timeOpen + "+ scaleOpen:" + scaleOpen + "+  alphaOpen:" + alphaOpen + "+  alphaOpenStep1:" + alphaOpenStep1 + "+  timeOpenStep1: " + timeOpenStep1 + "+  timeOpenStep1" + timeOpenStep1 + "+  scaleOpenStep1:" + scaleOpenStep1 + "+  timeSinceLevelLoad: " + Time.timeSinceLevelLoad);
                m_IfInitFinished = true;
                OnWindowOpen();
                Debug.Log("读取动画配置表成功" + prefix);
            }
            table = null;
        }