/// <summary>
        /// create MsgDecoder
        /// if error, use Debug.LogError
        /// </summary>
        /// <param name="msgType"></param>
        /// <returns></returns>
        public static MsgDecoder CreateInstance(Type msgType)
        {
            string     error;
            MsgDecoder decoder = CreateInstance(msgType, out error);

            if (decoder == null)
            {
                Debug.LogError(error);
            }
            return(decoder);
        }
        /// <summary>
        /// create MsgDecoder
        /// </summary>
        /// <param name="msgId"></param>
        /// <param name="msgType"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static MsgDecoder CreateInstance(Type msgType, out string error)
        {
            try
            {
                MethodInfo createBuilderMi = msgType.GetMethod("CreateBuilder", new Type[] { });
                if (createBuilderMi == null)
                {
                    error = "CreateBuilder method is not found";
                    return(null);
                }

                object builder = createBuilderMi.Invoke(null, null);
                if (builder == null)
                {
                    error = "builder == null";
                    return(null);
                }

                MethodInfo parseFromMi = msgType.GetMethod("ParseFrom", new[] { typeof(Stream) });
                if (parseFromMi == null)
                {
                    error = "ParseFrom method is not found";
                    return(null);
                }

                MsgDecoder decoder = new MsgDecoder();
                decoder.mParseFromMi = parseFromMi;
                decoder.BuilderType  = builder.GetType();
                error = null;
                return(decoder);
            }
            catch (Exception ex)
            {
                error = ex.ToString();
                return(null);
            }
        }