private static string GetType(ChannelsDefinition.Channel channel)
 {
     if (channel.type == ChannelsDefinition.ChannelType.Object)
     {
         if (channel.objectType.Length > 0)
         {
             return(channel.objectType);
         }
         else
         {
             return("object");
         }
     }
     else if (channel.type == ChannelsDefinition.ChannelType.Quaternion)
     {
         return("Quaternion");
     }
     else if (channel.type == ChannelsDefinition.ChannelType.Vector)
     {
         return("Vector3");
     }
     else
     {
         return(channel.type.ToString().ToLower());
     }
 }
        private static string GetChannelDefault(ChannelsDefinition.Channel def)
        {
            switch (def.type)
            {
            case ChannelsDefinition.ChannelType.Bool:
                return(def.defaultBool.ToString().ToLower());

            case ChannelsDefinition.ChannelType.Float:
                return(def.defaultFloat.ToString() + "f");

            case ChannelsDefinition.ChannelType.Int:
                return(def.defaultInt.ToString());

            case ChannelsDefinition.ChannelType.Vector:
                Vector3 v = def.defaultVector;
                return("new Vector3(" + v.x + "f, " + v.y + "f, " + v.z + "f)");

            case ChannelsDefinition.ChannelType.Quaternion:
                Quaternion q = Quaternion.Euler(def.defaultRotation);
                return("new Quaternion(" + q.x + "f, " + q.y + "f, " + q.z + "f, " + q.w + "f)");

            default:
                return("default(" + GetType(def) + ")");
            }
        }
 private static string GetSetter(ChannelsDefinition.Channel channel)
 {
     if (channel.type == ChannelsDefinition.ChannelType.Float && channel.floatHasRange)
     {
         return("Mathf.Clamp(value, " + channel.floatMin + "f, " + channel.floatMax + "f)");
     }
     else if (channel.type == ChannelsDefinition.ChannelType.Int && channel.intHasRange)
     {
         return("Mathf.Clamp(value, " + channel.intMin + ", " + channel.intMax + ")");
     }
     else if (channel.type == ChannelsDefinition.ChannelType.Vector && channel.vectorHasMax)
     {
         float sqr = channel.vectorMax * channel.vectorMax;
         return("value.sqrMagnitude > " + sqr + "f ? value.normalized * " + channel.vectorMax + "f : value");
     }
     else
     {
         return("value");
     }
 }
Пример #4
0
 private static string GetSetter(ChannelsDefinition.Channel channel)
 {
     if (channel.type == ChannelsDefinition.ChannelType.Float)
     {
         if (channel.floatHasRange)
         {
             return("SetFloat(\"" + channel.name + "\", value, " + channel.floatMin + ", " + channel.floatMax + ");");
         }
         else
         {
             return("SetFloat(\"" + channel.name + "\", value);");
         }
     }
     else if (channel.type == ChannelsDefinition.ChannelType.Int)
     {
         if (channel.intHasRange)
         {
             return("SetInt(\"" + channel.name + "\", value, " + channel.intMin + ", " + channel.intMax + ");");
         }
         else
         {
             return("SetInt(\"" + channel.name + "\", value);");
         }
     }
     else if (channel.type == ChannelsDefinition.ChannelType.Vector)
     {
         if (channel.vectorHasMax)
         {
             return("SetVector(\"" + channel.name + "\", value, " + channel.vectorMax + ");");
         }
         else
         {
             return("SetVector(\"" + channel.name + "\", value);");
         }
     }
     else
     {
         return("SetInput(\"" + channel.name + "\", value);");
     }
 }
        private static string GetClear(ChannelsDefinition.Channel channel)
        {
            string template = channel.clears ? clearTemplate : clearTemplateIf;

            return(string.Format(template, channel.name, GetChannelDefault(channel)));
        }
 private static string GetProperty(ChannelsDefinition.Channel channel)
 {
     return(string.Format(propertyTemplate, GetType(channel), channel.name, GetSetter(channel)));
 }
Пример #7
0
 private static string GetGetter(ChannelsDefinition.Channel channel)
 {
     return("return GetInput<" + GetType(channel) + ">(\"" + channel.name + "\");");
 }