示例#1
0
    static public Shader Compile(TCP2_Config config, string template, float progress, bool overwritePrompt, bool modifiedPrompt)
    {
        //UI
        if (progress >= 0f)
        {
            EditorUtility.DisplayProgressBar("Hold On", "Generating Shader: " + config.ShaderName, progress);
        }

        //Generate source
        string source = config.GenerateShaderSource(template);

        if (string.IsNullOrEmpty(source))
        {
            Debug.LogError("[TCP2 Shader Generator] Can't save Shader: source is null or empty!");
            return(null);
        }

        //Save to disk
        Shader shader = SaveShader(config, source, overwritePrompt, modifiedPrompt);

        //UI
        if (progress >= 0f)
        {
            EditorUtility.ClearProgressBar();
        }

        return(shader);
    }
	static public Shader Compile(TCP2_Config config, Shader existingShader, string template, float progress, bool overwritePrompt, bool modifiedPrompt)
	{
		//UI
		if(progress >= 0f)
			EditorUtility.DisplayProgressBar("Hold On", "Generating Shader: " + config.ShaderName, progress);
		
		//Generate source
		string source = config.GenerateShaderSource(template, existingShader);
		if(string.IsNullOrEmpty(source))
		{
			Debug.LogError("[TCP2 Shader Generator] Can't save Shader: source is null or empty!");
			return null;
		}

		//Save to disk
		Shader shader = SaveShader(config, existingShader, source, overwritePrompt, modifiedPrompt);

		if(config.configType == "terrain")
		{
			//Generate Base shader
			TCP2_Config baseConfig = config.Copy();
			baseConfig.Filename = baseConfig.Filename + "_Base";
			baseConfig.ShaderName = "Hidden/" + baseConfig.ShaderName + "-Base";
			baseConfig.Features.Add("TERRAIN_BASE");

			source = baseConfig.GenerateShaderSource(template, existingShader);
			if (string.IsNullOrEmpty(source))
				Debug.LogError("[TCP2 Shader Generator] Can't save Terrain Base Shader: source is null or empty!");
			else
				SaveShader(baseConfig, existingShader, source, false, false);

			//Generate AddPass shader
			TCP2_Config addPassConfig = config.Copy();
			addPassConfig.Filename = addPassConfig.Filename + "_AddPass";
			addPassConfig.ShaderName = "Hidden/" + addPassConfig.ShaderName + "-AddPass";
			addPassConfig.Features.Add("TERRAIN_ADDPASS");
			addPassConfig.Flags.Add("decal:add");

			source = addPassConfig.GenerateShaderSource(template, existingShader);
			if (string.IsNullOrEmpty(source))
				Debug.LogError("[TCP2 Shader Generator] Can't save Terrain AddPass Shader: source is null or empty!");
			else
				SaveShader(addPassConfig, existingShader, source, false, false);
		}

		//UI
		if(progress >= 0f)
			EditorUtility.ClearProgressBar();

		return shader;
	}
    public static Shader Compile(TCP2_Config config, string template, float progress, bool overwritePrompt, bool modifiedPrompt)
    {
        //UI
        if(progress >= 0f)
            EditorUtility.DisplayProgressBar("Hold On", "Generating Shader: " + config.ShaderName, progress);

        //Generate source
        string source = config.GenerateShaderSource(template);
        if(string.IsNullOrEmpty(source))
        {
            Debug.LogError("[TCP2 Shader Generator] Can't save Shader: source is null or empty!");
            return null;
        }

        //Save to disk
        Shader shader = SaveShader(config, source, overwritePrompt, modifiedPrompt);

        //UI
        if(progress >= 0f)
            EditorUtility.ClearProgressBar();

        return shader;
    }