private static string GetConstructor(ChannelsDefinition def)
        {
            string str = "";

            foreach (var channel in def.channels)
            {
                str += "        RegisterInputChannel(\"" + channel.name + "\", " + GetChannelDefault(channel) + ", " + channel.clears.ToString().ToLower() + ");\n";
            }

            return(str);
        }
        private static string GetProperties(ChannelsDefinition def)
        {
            string str = "";

            foreach (var channel in def.channels)
            {
                str += GetProperty(channel);
            }

            return(str);
        }
        public override void OnInspectorGUI()
        {
            if (GUILayout.Button("Generate Class"))
            {
                var path = AssetDatabase.GetAssetPath(target);
                if (path.Length > 0)
                {
                    ChannelsClassGenerator.GenerateClass(target as ChannelsDefinition);
                }
            }

            ChannelsDefinition def = target as ChannelsDefinition;

            DrawDefaultInspector();
        }
        public static void GenerateClass(ChannelsDefinition def)
        {
            string generated = string.Format(classTemplate, def.name, GetConstructor(def), GetProperties(def), def.baseClass);

            string defPath = AssetDatabase.GetAssetPath(def);

            if (defPath.Length > 0)
            {
                string newPath = defPath.Substring(0, defPath.LastIndexOf(".")) + ".cs";

                StreamWriter outStream = new StreamWriter(newPath);
                outStream.Write(generated);
                outStream.Close();
                AssetDatabase.Refresh();
            }
        }