Exemplo n.º 1
0
    public static void LogFormatObjects(string channel, DebugPrintModifier mod, DebugOutDelegate dOutDel,
		DebugObjectInfoDelegate dObjInfoDel, string header, object [] objArray)
    {
        DebugChannelState dState = null;

        if((debugChannels.TryGetValue(channel, out dState) == true) &&
            (dState.state == ChannelState.On))
        {
            if((mod & (DebugPrintModifier.Channel | DebugPrintModifier.Default )) != 0)
            {
                outString.Length = 0;
                outString.Append(channel);
                outString.Append(" ; \n");
            }

            //Line number header.
            if((mod & DebugPrintModifier.LineNumber) != 0)
            {
                outString.Append("No.;");
            }

            //If there is a header, print it.
            if(header != null)
            {
                outString.Append(header);
                outString.Append("\n");
            }

            //We may need to print this in more than one go due to the
            //limited size of Unitys debug buffer..
            object ob = null;
            for(int i = 0; i < objArray.Length; i++)
            {
                ob = objArray[i];

                //Line number at beginning of line.
                if((mod & DebugPrintModifier.LineNumber) == DebugPrintModifier.LineNumber)
                {
                    outString.Append(i);
                    outString.Append(";");
                }
                //New line per object print.
                if((mod & DebugPrintModifier.NewLine) != 0)
                {
                    outString.AppendFormat(" {0}\n", ((dObjInfoDel == null) ? ob : dObjInfoDel(ob)));
                }
                else
                {
                    outString.AppendFormat(" {0}", ((dObjInfoDel == null) ? ob : dObjInfoDel(ob)));
                }

                //check whether we have buffer space left for more object prints.
                if(outString.Length > (OutStringMaxSize - OutSafetyMargin))
                {
                    //print it and reset the out string, we'll make another debug entry.
                    if(dOutDel != null)
                    {
                        dOutDel(outString.ToString(), false);
                    }
                    else
                    {
                        Debug.Log(outString);
                    }
                    outString.Length = 0;
                }
            }

            //print it and reset the out string, we'll make another debug entry.
            if(dOutDel != null)
            {
                dOutDel(outString.ToString(), true);
            }
            else
            {
                Debug.Log(outString);
            }
            outString.Length = 0;
        }
    }
Exemplo n.º 2
0
    public static void LogFormatObjects(string channel, DebugPrintModifier mod, DebugOutDelegate dOutDel,
		DebugObjectInfoDelegate dObjInfoDel, string header, object obj)
    {
        object [] objArray = {obj};

        LogFormatObjects(channel, mod, dOutDel, dObjInfoDel, header, objArray);
    }