コード例 #1
0
        public void OnShow(GameObject showObj)
        {
            if (showObj != null)
            {
                ShowObj = showObj;
            }
            if (Parent != null && !Parent.Equals(null))
            {
                Transform showTrans = showObj.transform;
                showTrans.SetParent(Parent);
                showTrans.localEulerAngles = Rotation;
                showTrans.localScale       = Scale;
                showTrans.localPosition    = Position;
                MonoTool.SetLayer(showObj, true, "UI");
                if (MaskEx != null)
                {
                    MaskEx.OnUpdate();
                }

                if (UIDepth != null)
                {
                    UIDepth.SetOrder(UIDepth.Order);
                }

                if (!showObj.activeSelf)
                {
                    showObj.SetActive(true);
                }
            }
        }
コード例 #2
0
    public static void OnPingBack(long t)
    {
        long curr = MonoTool.GetTimeStamp();
        long dt   = (curr - t) / 2;

        if (m_PingCount <= m_LastPingTimeOfLoop)
        {
            if (m_PingCount < m_PingTimes.Count)
            {
                m_PingTimes[m_PingCount] = dt;
            }
            else
            {
                m_PingTimes.Add(dt);
            }
            m_PingCount++;
        }
        else
        {
            m_LastPingTimeOfLoop = curr;
            m_PingCount          = 0;
            JiSuanPing();
            if (m_PingChangeCall != null)
            {
                m_PingChangeCall(m_PingValue);
            }
        }
        m_PingBack = true;
        m_bDrop    = false;
        m_SendPing = false;
    }
コード例 #3
0
    public static string makeFullPath(string strFileName)
    {
        string strFullName = "";

        if (strFileName == null)
        {
            return(null);
        }
        strFullName = Path.Combine(MonoTool.GetPersistentPath(), strFileName);

        //对该路径进行检测,如果没有找到,就为他尽量指定一个默认路径
        if (File.Exists(strFullName))
        {
            //Debug.Log("file find at manu folder,path is" + strFullName);
            return(strFullName);
        }
        else
        {
            //Debug.Log("file not find at the path : " + strFullName + " ,using File.Exists for test");
            strFullName = MonoTool.GeDataPathHeader() + Path.Combine(MonoTool.GetDataPath(), strFileName);
            //Debug.Log("change path to system path :" + strFullName);
        }

        //Debug.LogError("makeFullPath:" + strFullName);
        return(strFullName);
    }
コード例 #4
0
 private void OnGUI()
 {
     if (GUI.Button(new Rect(Screen.width * 0.5f, Screen.height * 3 / 8, Screen.width / 7, Screen.height / 8), "测试"))
     {
         MonoTool.ReplaceMissScript();
     }
 }
コード例 #5
0
 public static string GetDataPath()
 {
     if (m_DataPath != "")
     {
         return(m_DataPath);
     }
     m_DataPath = MonoTool.GeDataPathHeader() + MonoTool.GetDataPath();
     //Debug.LogError("getSystemPath:" + path);
     return(m_DataPath);
 }
コード例 #6
0
    public static void Update()
    {
        if (!m_OpenPing)
        {
            return;
        }
        float dt    = UnityEngine.Time.deltaTime;
        long  mmsec = (long)(dt * 1000);
        long  curr  = MonoTool.GetTimeStamp();

        if (m_SendPing)
        {
            if (!m_PingBack)
            {
                m_PingBackPastTime += mmsec;
                if (m_PingBackPastTime >= m_PingBackWaitTime)
                {
                    m_bDrop = true;
                }

                return;
            }
        }
        else
        {
            if (curr - m_LastPingTimeOfLoop > m_PingIntervalOfLoop)
            {
                if (m_PingPastTime >= m_PingInterval)
                {
                    MonoMessage.ReqHeart(curr);
                    m_PingPastTime     = 0;
                    m_PingBack         = false;
                    m_SendPing         = true;
                    m_PingBackPastTime = 0;
                    m_bDrop            = false;
                }
                else
                {
                    m_PingPastTime += mmsec;
                }
            }
        }
    }
コード例 #7
0
    public void Initialize(System.Action initOK)
    {
        string manifestName = MonoTool.GetRuntimePlatformName() + MonoTool.GetAssetbundleSuffix();

        m_fLastGCTime = Time.realtimeSinceStartup;
        //注意这里的 "AssetBundleManifest" 参数是和bundle文件的主bundle的manifest文件里面的AssetBundleManifest对应的,不能随意修改
        LoadAsset(typeof(AssetBundleManifest), manifestName, new string[] { "AssetBundleManifest" },
                  (ABObject objs) =>
        {
            if (objs.m_UObjectList.Count > 0)
            {
                m_AssetBundleManifest = objs.m_UObjectList[0] as AssetBundleManifest;
            }
            if (initOK != null)
            {
                initOK();
            }
        });
    }
コード例 #8
0
ファイル: UIManager.cs プロジェクト: zjljxsc/cshotfix
        private static T WindowCreateEX <T>(WindowBase parent, params object[] param) where T : WindowBase, new()
        {
            T      win    = new T();
            string uifile = typeof(T).Name;

            if (win != null)
            {
                StringBuilder sb     = Tool.StringBuilder.AppendFormat("ui/{0}" + MonoTool.GetAssetbundleSuffix(), uifile.ToLower());
                string        abname = sb.ToString();
                sb.Clear();
                win.SetLogicOpen(true);
                win.m_UIName = uifile;
                win.SetUserData(param);
                win.m_ABId = ResourceManager.LoadPrefab(typeof(GameObject), abname, uifile, (abobject) =>
                {
                    #region 异步加载UI资源回调
                    win.m_WinObj           = (GameObject)GameObject.Instantiate(abobject.m_UObjectList[0]);
                    win.m_WinTransform     = win.m_WinObj.transform;
                    Transform AttachObject = GetLayer(win.m_Layer);

                    if (AttachObject == null)
                    {
                        UnityEngine.Debug.LogWarning("挂节点没有找到");
                        return;
                    }
                    //先将大小还原到他的父对象的局部坐标
                    Vector3 parentScale           = AttachObject.localScale;
                    Vector3 now                   = win.m_WinTransform.localScale;
                    Vector3 childScale            = new Vector3(now.x * parentScale.x, now.y * parentScale.y, now.z * parentScale.z);
                    win.m_WinTransform.localScale = childScale;


                    //挂接到对应的位置
                    RectTransform rect = win.m_WinObj.GetComponent(typeof(RectTransform)) as RectTransform;
                    if (rect != null)
                    {
                        Vector3 pos = rect.anchoredPosition3D;

                        Quaternion rotation = rect.localRotation;

                        Vector3 scale = rect.localScale;

                        Vector2 offsetMax = rect.offsetMax;

                        Vector2 offsetMin = rect.offsetMin;

                        win.m_WinTransform.SetParent(AttachObject);
                        rect.anchoredPosition3D = pos;
                        rect.localRotation      = rotation;
                        rect.localScale         = scale;


                        rect.offsetMax = offsetMax;
                        rect.offsetMin = offsetMin;
                    }
                    win.m_WindowPos = win.m_WinTransform.position;
                    win.ShowWindowObj();
                    //设置该layer下面层级
                    List <WindowBase> wins = GetWindowsByLayer(win.m_Layer);
                    SortLayerWindows(wins, win.m_Layer);
                    win.m_WindowPos = win.m_WinTransform.position;
                    win.DoWindowDataBind();

                    #endregion
                });
                if (parent != null)
                {
                    parent.AddChild(win);
                }
                m_OpenedList.Add(win);
                //添加逻辑窗口和层的对应关系
                List <WindowBase> winList = GetWindowsByLayer(win.m_Layer);
                if (winList != null)
                {
                    winList = AddWindowToParentLast(winList, win, parent);
                }
                else
                {
                    winList = new List <WindowBase>();
                    winList = AddWindowToParentLast(winList, win, parent);
                    m_LayerWindows.Add((int)win.m_Layer, winList);
                }
                return(win);
            }
            else
            {
                UnityEngine.Debug.LogError("打开的窗口不存在," + uifile);
            }
            return(null);
        }
コード例 #9
0
ファイル: InputManager.cs プロジェクト: ErQing/cshotfix
        public static void UpdateRoleMove()
        {
            float x = MonoTool.GetInputAxisX();

            m_JoystickValue.x = x;
            float y = MonoTool.GetInputAxisY();

            m_JoystickValue.y = y;
            float precision = 0.01f;

            if (m_MoveState != MoveState.None && m_MoveState != MoveState.Stop)
            {
                //UnityEngine.Debug.Log(m_MoveState.ToString() + " x:" + x.ToString("F4") + "y:" + y.ToString("F4") + " lastX:" + m_LastJoystickX.ToString("F4") + " lastY:" + m_LastJoystickY.ToString("F4"));
            }

            switch (m_MoveState)
            {
            case MoveState.None:
            {
                if (Math.Abs(x) > precision || Math.Abs(y) > precision)
                {
                    JoystickChangeDir();
                    m_MoveState     = MoveState.DirStartStopMoveTest;
                    m_LastJoystickX = x;
                    m_LastJoystickY = y;
                }
                break;
            }

            case MoveState.DirStartStopMoveTest:
            {
                if (Math.Abs(m_LastJoystickX - x) < precision && Math.Abs(m_LastJoystickY - y) < precision)
                {
                    m_MoveState     = MoveState.TestStopMoveTime;
                    m_MovingDirTime = Time.timeSinceLevelLoad;
                }
                m_LastJoystickX = x;
                m_LastJoystickY = y;
                if (Math.Abs(x) < precision && Math.Abs(y) < precision)
                {
                    m_MoveState = MoveState.Stop;
                }

                break;
            }

            case MoveState.TestStopMoveTime:
            {
                if (Math.Abs(m_LastJoystickX - x) < precision && Math.Abs(m_LastJoystickY - y) < precision)
                {
                    if (Time.timeSinceLevelLoad - m_MovingDirTime > 0.1f)
                    {
                        JoystickChangeDir();
                        //UnityEngine.Debug.Log("JoystickChangeDir");
                        m_MoveState = MoveState.TestStartMove;

                        m_LastJoystickX = x;
                        m_LastJoystickY = y;
                    }
                }
                else
                {
                    m_LastJoystickX = x;
                    m_LastJoystickY = y;
                    m_MoveState     = MoveState.DirStartStopMoveTest;
                }


                if (Math.Abs(x) < precision && Math.Abs(y) < precision)
                {
                    m_MoveState = MoveState.Stop;
                }
                break;
            }

            case MoveState.TestStartMove:
            {
                if (Math.Abs(m_LastJoystickX - x) > precision || Math.Abs(m_LastJoystickY - y) > precision)
                {
                    m_MoveState     = MoveState.DirStartStopMoveTest;
                    m_LastJoystickX = x;
                    m_LastJoystickY = y;
                }

                if (Math.Abs(x) < precision && Math.Abs(y) < precision)
                {
                    m_MoveState = MoveState.Stop;
                }
                break;
            }

            case MoveState.Stop:
            {
                JoystickStopMove();
                m_MoveState = MoveState.None;
                break;
            }
            }
        }
コード例 #10
0
 protected override void OnOpen()
 {
     MonoTool.SetMoveBase(false);
 }