示例#1
0
        private static string GetProperties(ChannelsDefinition def)
        {
            string str = "";

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

            return(str);
        }
示例#2
0
        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);
        }
        public static void GenerateClass(ChannelsDefinition def)
        {
            string generated = string.Format(classTemplate, def.name, def.baseClass, GetProperties(def), GetClears(def));

            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();
            }
        }
 private static string GetClears(ChannelsDefinition def)
 {
     return(string.Join("", def.channels.Select(c => GetClear(c))));
 }
 private static string GetProperties(ChannelsDefinition def)
 {
     return(string.Join("", def.channels.Select(c => GetProperty(c))));
 }