Beispiel #1
0
    void Awake()
    {
        //transform_ = transform;

        //记录各功能按钮的展开状态下的位置
        for (int i = 0; i < funtions_trans_.childCount; i++)
        {
            Transform     info_trans = funtions_trans_.GetChild(i);
            Vector3       info_pos   = info_trans.localPosition;
            Function_Info info       = new Function_Info(info_trans, info_pos);
            function_info_list_.Add(info);
        }

        UIEventListener.Get(in_btn_object_).onClick  = StrecthAllIn;
        UIEventListener.Get(out_btn_object_).onClick = StrecthAllOut;
        if (null != btn_object_)
        {
            //UIEventListener.Get(btn_object_).onClick = StrecthAll;
        }

        if (strecth_in_ > 0)
        {
            strecth_status_ = EStrecthStatus.StrecthStatus_Outed;
            StrecthAllIn(null);
        }
        else
        {
            strecth_status_ = EStrecthStatus.StrecthStatus_Ined;
            StrecthAllOut(null);
        }
    }
Beispiel #2
0
 public void StrecthAllIn(GameObject go)
 {
     //strecth outed状态下,处理完相应操作后,才能改状态为strecth ining
     if (strecth_status_ == EStrecthStatus.StrecthStatus_Outed)
     {
         //隐蔽in按钮,显示out按钮
         in_btn_object_.SetActive(false);
         out_btn_object_.SetActive(true);
         strecth_status_ = EStrecthStatus.StrecthStatus_Ining;
     }
 }
Beispiel #3
0
 void StrecthAllOut(GameObject go)
 {
     //strecth ined状态下,处理完相应操作后,才能改状态为strecth outing
     if (strecth_status_ == EStrecthStatus.StrecthStatus_Ined)
     {
         //隐蔽out按钮,显示in按钮
         out_btn_object_.SetActive(false);
         in_btn_object_.SetActive(true);
         //显示各个功能按钮
         for (int i = 0; i < funtions_trans_.childCount; i++)
         {
             Function_Info info = function_info_list_[i];
             info.fun_transform.gameObject.SetActive(true);
             UIWidget[] widgets = info.fun_transform.GetComponentsInChildren <UIWidget>();
             int        wNum    = widgets.Length;
             for (int j = 0; j < wNum; j++)
             {
                 widgets[j].alpha = 1f;
             }
         }
         strecth_status_ = EStrecthStatus.StrecthStatus_Outing;
     }
 }
Beispiel #4
0
    void Update()
    {
        int funtionnum = function_info_list_.Count;

        //0个功能按钮不用处理
        if (funtionnum > 0)
        {
            //strecth ining状态下才能缩入
            if (strecth_status_ == EStrecthStatus.StrecthStatus_Ining)
            {
                //按位移比例来移动
                for (int i = 0; i < funtionnum; i++)
                {
                    Function_Info info = function_info_list_[i];
                    info.fun_transform.Translate(-Time.deltaTime * info.fun_position * strecth_speed_);
                }
                Function_Info info0 = function_info_list_[0];
                //当其中一个达到指定位置就改状态为strecth ined
                if ((right_side_ == 0 && info0.fun_transform.localPosition.x > 0 - strecth_cache_) ||
                    (right_side_ > 0 && info0.fun_transform.localPosition.x < strecth_cache_))
                {
                    //隐藏各个功能按钮
                    for (int i = 0; i < funtions_trans_.childCount; i++)
                    {
                        Function_Info info    = function_info_list_[i];
                        UIWidget[]    widgets = info.fun_transform.GetComponentsInChildren <UIWidget>();
                        int           wNum    = widgets.Length;
                        for (int j = 0; j < wNum; j++)
                        {
                            widgets[j].alpha = 0f;
                        }
                        info.fun_transform.gameObject.SetActive(false);
                        //移动时产生浮点误差,要调回正确位置
                        info.fun_transform.localPosition = new Vector3(0, 0, 0);
                    }
                    strecth_status_ = EStrecthStatus.StrecthStatus_Ined;
                }
            }
            //strecth outing状态下才能伸展
            else if (strecth_status_ == EStrecthStatus.StrecthStatus_Outing)
            {
                //按位移比例来移动
                for (int i = 0; i < funtionnum; i++)
                {
                    Function_Info info = function_info_list_[i];
                    info.fun_transform.Translate(Time.deltaTime * info.fun_position * strecth_speed_);
                }
                Function_Info info0 = function_info_list_[0];
                //当其中一个达到指定位置就改状态为strecth outed
                if ((right_side_ == 0 && info0.fun_transform.localPosition.x < info0.fun_position.x + strecth_cache_) ||
                    (right_side_ > 0 && info0.fun_transform.localPosition.x > info0.fun_position.x - strecth_cache_))
                {
                    //移动时产生浮点误差,要调回正确位置
                    for (int i = 0; i < funtions_trans_.childCount; i++)
                    {
                        Function_Info info = function_info_list_[i];
                        info.fun_transform.localPosition = info.fun_position;
                    }
                    strecth_status_ = EStrecthStatus.StrecthStatus_Outed;
                }
            }
        }
    }