Esempio n. 1
0
        public bool Handle_VarTracerInfo(eNetCmd cmd, UsCmd c)
        {
            int groupCount = c.ReadInt32();

            //NetUtil.Log("read group count: {0}.", groupCount);

            for (int i = 0; i < groupCount; i++)
            {
                var groupName = c.ReadString();
                //NetUtil.Log("read group Name: {0}.", groupName);
                var variableCount = c.ReadInt32();
                //NetUtil.Log("read var count : {0}.", variableCount);
                for (int j = 0; j < variableCount; j++)
                {
                    var variableName = c.ReadString();
                    //NetUtil.Log("read variableName: {0}.", variableName);
                    var sessionCount = c.ReadInt32();
                    //NetUtil.Log("read sessionCount: {0}.", sessionCount);
                    for (int k = 0; k < sessionCount; k++)
                    {
                        long stamp = c.ReadLong();
                        if (VarTracerNet.Instance.StartTimeStamp == 0)
                        {
                            VarTracerNet.Instance.StartTimeStamp = VarTracerUtils.GetTimeStamp();
                            VarTracerNet.Instance.NetDeltaTime   = VarTracerNet.Instance.StartTimeStamp - stamp;
                        }
                        stamp += VarTracerNet.Instance.NetDeltaTime;

                        //NetUtil.Log("read stamp: {0}.", stamp);
                        float value = c.ReadFloat();
                        //NetUtil.Log("read value: {0}.", value);
                        VarTracerHandler.UpdateVariable(groupName, variableName, stamp, value);
                    }
                }

                var eventCount = c.ReadInt32();
                for (int j = 0; j < eventCount; j++)
                {
                    var eventName    = c.ReadString();
                    var sessionCount = c.ReadInt32();
                    for (int k = 0; k < sessionCount; k++)
                    {
                        long  stamp    = c.ReadLong();
                        float duration = c.ReadFloat();
                        VarTracerHandler.SendEvent(groupName, stamp, eventName, duration);
                    }
                }
            }

            return(true);
        }
        void OnEnable()
        {
            Application.runInBackground = true;
            EditorApplication.update   += Update;
            if (VarTracer.Instance != null)
            {
                if (VarTracer.Instance.Graphs.Count == 0)
                {
                    VarTracer.AddChannel();
                }

                bool constainsCamera = VarTracer.Instance.groups.ContainsKey("Camera");
                if (!constainsCamera || VarTracer.Instance.groups["Camera"].VariableDict.Count == 0)
                {
                    //VarTracerHandler.DefineVariable("CameraV_X", "Camera");
                    //VarTracerHandler.DefineVariable("CameraV_Y", "Camera");
                    //VarTracerHandler.DefineVariable("CameraV_Z", "Camera");
                    //VarTracerHandler.DefineVariable("CameraV_T", "Camera");

                    VarTracerHandler.DefineVariable("PlayerV_X", "Player");
                    VarTracerHandler.DefineVariable("PlayerV_Y", "Player");
                    VarTracerHandler.DefineVariable("PlayerV_Z", "Player");
                    VarTracerHandler.DefineVariable("CameraV_T", "Camera");

                    VarTracerHandler.DefineVariable("FPS", "System");

                    VarTracerHandler.DefineEvent("JUMP", "Camera");
                    VarTracerHandler.DefineEvent("ATTACK", "Camera");

                    //VarTracerHandler.DefineVariable("NpcV_X", "Npc");
                    //VarTracerHandler.DefineVariable("NpcV_Y", "Npc");
                    //VarTracerHandler.DefineVariable("NpcV_Z", "Npc");
                    //VarTracerHandler.DefineVariable("NpcV_T", "Npc");
                }
            }
            VarTracer.AddChannel();
        }