Ejemplo n.º 1
0
    public static void UpdateVariable(string variableName, float value)
    {
        VarTracerJsonType vtjt = new VarTracerJsonType();

        vtjt.variableName  = new string[] { variableName };
        vtjt.variableValue = new float[] { value };
        VarTracerSender.Instance.SendJsonMsg(vtjt);
    }
Ejemplo n.º 2
0
    public static void SendEvent(string eventName, float duration = 0, string desc = "")
    {
        VarTracerJsonType vtjt = new VarTracerJsonType();

        vtjt.eventName     = new string[] { eventName };
        vtjt.eventDuration = new float[] { duration };
        vtjt.eventDesc     = new string[] { desc };
        VarTracerSender.Instance.SendJsonMsg(vtjt);
    }
Ejemplo n.º 3
0
    public static void DefineVariable(string variableName, string LogicalName)
    {
        VarTracerJsonType vtjt = new VarTracerJsonType();

        vtjt.logicName     = LogicalName;
        vtjt.variableName  = new string[] { variableName };
        vtjt.variableValue = new float[] { 0 };
        VarTracerSender.Instance.SendJsonMsg(vtjt);
    }
Ejemplo n.º 4
0
    public static void ResoloveJsonMsg(VarTracerJsonType resolved)
    {
        int variableCount = resolved.variableName.Length;

        if (variableCount != resolved.variableValue.Length)
        {
            Debug.LogErrorFormat("Parameter Resolove Json Error ,variableCount = {0}", variableCount);
        }
        int eventCount = resolved.eventName.Length;

        if (eventCount != resolved.eventDuration.Length || eventCount != resolved.eventDesc.Length)
        {
            Debug.LogErrorFormat("Parameter Resolove Json Error ,eventCount = {0}", eventCount);
        }

        long timeStamp = resolved.timeStamp;

        if (VarTracerNet.Instance.StartTimeStamp == 0)
        {
            VarTracerNet.Instance.StartTimeStamp = VarTracerUtils.GetTimeStamp();
            VarTracerNet.Instance.NetDeltaTime   = VarTracerNet.Instance.StartTimeStamp - timeStamp;
        }
        timeStamp += VarTracerNet.Instance.NetDeltaTime;

        bool hasLogicalName = !string.IsNullOrEmpty(resolved.logicName);

        for (int i = 0; i < variableCount; i++)
        {
            if (hasLogicalName)
            {
                DefineVariable(resolved.variableName[i], resolved.logicName);
            }
            UpdateVariable(timeStamp, resolved.variableName[i], resolved.variableValue[i]);
        }

        for (int i = 0; i < eventCount; i++)
        {
            if (hasLogicalName)
            {
                DefineEvent(resolved.eventName[i], resolved.logicName);
            }
            if (resolved.eventDuration[i] != -1)
            {
                SendEvent(timeStamp, resolved.eventName[i], resolved.eventDuration[i], resolved.eventDesc[i]);
            }
        }

        if (resolved.runingState == (int)VarTracerConst.RunningState.RunningState_Start)
        {
            StartVarTracer();
        }
        else if (resolved.runingState == (int)VarTracerConst.RunningState.RunningState_Pause)
        {
            StopVarTracer();
        }
    }
Ejemplo n.º 5
0
    public static void DefineEvent(string eventName, string variableBody)
    {
        VarTracerJsonType vtjt = new VarTracerJsonType();

        vtjt.logicName     = variableBody;
        vtjt.eventName     = new string[] { eventName };
        vtjt.eventDuration = new float[] { -1 };
        vtjt.eventDesc     = new string[] { "" };
        VarTracerSender.Instance.SendJsonMsg(vtjt);
    }
Ejemplo n.º 6
0
 public void handleMsgAsyn(object o)
 {
     string[]            strArray = (string[])o;
     VarTracerJsonType[] writeVjt = new VarTracerJsonType[strArray.Length];
     for (int i = 0; i < strArray.Length; i++)
     {
         var str      = strArray[i];
         var resolved = JsonUtility.FromJson <VarTracerJsonType>(str);
         //Debug.LogFormat("Rec = {0}",resolved.testIndex);
         writeVjt[i] = resolved;
     }
     vartracerJsonObj.writeResovleJsonResult(writeVjt);
 }
Ejemplo n.º 7
0
 public void SendJsonMsg(VarTracerJsonType vtjt)
 {
     if (vtjt.timeStamp == 0)
     {
         vtjt.timeStamp = VarTracerUtils.GetTimeStamp();
     }
     lock (_locker)
     {
         if (isMainMsgList)
         {
             sendMsgList.Add(vtjt);
         }
         else
         {
             sendMsgTempList.Add(vtjt);
         }
     }
 }
Ejemplo n.º 8
0
    public static void SendGroupLoop(Group vjp)
    {
        if (vjp == null)
        {
            return;
        }

        VarTracerJsonType vtjt = new VarTracerJsonType();

        vtjt.logicName   = vjp.Name;
        vtjt.runingState = vjp.RuningState;

        if (vjp.VarItems != null)
        {
            int count = vjp.VarItems.Length;
            vtjt.variableName  = new string [count];
            vtjt.variableValue = new float[count];
            for (int i = 0; i < count; i++)
            {
                vtjt.variableName[i]  = vjp.VarItems[i].VariableName;
                vtjt.variableValue[i] = vjp.VarItems[i].VariableValue;
            }
        }

        if (vjp.EventItems != null)
        {
            int count = vjp.EventItems.Length;
            vtjt.eventName     = new string[count];
            vtjt.eventDuration = new float[count];
            vtjt.eventDesc     = new string[count];
            for (int i = 0; i < count; i++)
            {
                vtjt.eventName[i]     = vjp.EventItems[i].EventName;
                vtjt.eventDuration[i] = vjp.EventItems[i].EventDuration;
                vtjt.eventDesc[i]     = vjp.EventItems[i].EventDesc;
            }
        }

        VarTracerSender.Instance.SendJsonMsg(vtjt);
    }