private static void AutoModify()
 {
     Debug.Log("auto modify file and class...");
     CollectAttributeUtil.InitialCollectModifyAttribute();
     CreateParticalClass();
     ChangOrginalClass();
 }
    private bool NotifyToChangeVarialbe(string input)
    {
        bool bresult = false;

        string[] splits = input.Split(' ');
        if (splits.Length != 3)
        {
            return(bresult);
        }

        string tempValue    = null;
        string messageInfor = (splits[0] + "_" + splits[1]).ToUpper();

        bresult = CollectAttributeUtil.IsVarialbeInList(splits[0], (splits[0] + "#" + splits[1]), out tempValue);
        if (bresult)
        {
            string getvaluve = splits[2];
            object variable  = new object();
            if ("int" == tempValue)
            {
                int tempvia = -1;
                int.TryParse(getvaluve, out tempvia);
                variable = tempvia;
            }
            if ("float" == tempValue)
            {
                float tempvia = -1;
                float.TryParse(getvaluve, out tempvia);
                variable = tempvia;
            }
            if ("string" == tempValue)
            {
                variable = getvaluve;
            }
            if ("bool" == tempValue)
            {
                bool tempvia = false;
                bool.TryParse(getvaluve, out tempvia);
                variable = tempvia;
            }
            NotificationManager.Instance.Notify(messageInfor, variable);
        }

        return(bresult);
    }
 //
 // Create console window, register callbacks
 //
 void Awake()
 {
     DontDestroyOnLoad(gameObject);
     CollectAttributeUtil.InitialCollectModifyAttribute();
     Debug.Log("Console Started");
 }
 private static void ClearCode()
 {
     Debug.Log("Clear all modification attribute properties ...");
     CollectAttributeUtil.ClearCollection();
 }
    private static void AddFunctionToClass(string filefullPath, AttributeForClass[] ClassName_VariableList)
    {
        if (string.IsNullOrEmpty(filefullPath) || ClassName_VariableList.Length <= 0)
        {
            return;
        }

        const char flagbit            = '#';
        string     ClassName_Variable = "";
        int        hashIndex          = -1;
        string     variable;
        string     collectSubscribeReference = string.Empty;
        int        ListLength       = ClassName_VariableList.Length;
        string     tempVarialbeType = string.Empty;

        using (StreamWriter writer = new StreamWriter(filefullPath, true))
        {
            //1. need regist function.
            StringBuilder output = new StringBuilder();
            for (int i = 0; i < ListLength; i++)
            {
                ClassName_Variable = ClassName_VariableList[i].class_variable;
                if (string.IsNullOrEmpty(ClassName_Variable) || !ClassName_Variable.Contains("#"))
                {
                    continue;
                }
                //
                hashIndex = ClassName_Variable.IndexOf(flagbit);
                variable  = ClassName_Variable.Substring(hashIndex + 1);
                //Debug.Log(" varible name is " + ClassName_Variable);
                ClassName_Variable         = ClassName_Variable.Replace(flagbit, '_');
                collectSubscribeReference += "#" + ClassName_Variable;

                // write file head information.
                output.Append("// " + ClassName_Variable + "\n");
                // message funtion.
                output.Append("private void " + ClassName_Variable + "(SLQJ.MessageObject obj)\n");
                output.Append("{\n");
                // accroding to the type to change.
                output.Append(variable + " = ");
                tempVarialbeType = CollectAttributeUtil.CheckVariableType(ClassName_VariableList[i].variable_type);
                output.Append("(" + tempVarialbeType + ")" + "obj.MsgValue;\n");
                output.Append("}\n\n");
            }
            writer.WriteLine(output.ToString());
            output.Remove(0, output.Length);

            //2. write file regist information.
            string[] registStringList = collectSubscribeReference.Split(flagbit);
            int      registLength     = registStringList.Length;
            output.Append("// add auto regist \n");
            // regist function
            output.Append("private void " + "Start4AutoSubscribe()\n");
            output.Append("{\n");
            for (int j = 1; j < registLength; j++)
            {
                output.Append("NotificationManager.Instance.Subscribe(" + "\"" + registStringList[j].ToUpper() + "\", "
                              + registStringList[j] + ");\n");
            }
            output.Append("\nDebug.Log(\"partical class start to regist\");\n");
            output.Append("}\n");

            //3. complete the class
            output.Append("\n//auto create partical code end.\n} \n\n");
            writer.WriteLine(output.ToString());
            writer.Close();
        }
    }