寫了一段時間shader,覺得還是有必要找個合適的IDE,以達到事半功倍的效果,提高效率。
1.最早官方的MonoDevelop編輯器
2.Visual Studio
3. Visual Studio Code +擴展組件unity3d-pack
其中unity3d-pack包含ShaderlabVSCode(Free)
4.Visual Studio 2017 + HLSL Tools for Visual Studio
5.Visual Studio +ShaderlabVS
6.Sublime Text + Unity-Shader
介紹安裝教程
構建這個插件作者的教程
對於設置環境變量很麻煩可以直接設置成對應的程序運行地址
using UnityEngine;
using UnityEditor;
using System;
public class LuaTxtEditor
{
//http://www.xuanyusong.com/archives/3702
[UnityEditor.Callbacks.OnOpenAssetAttribute(1)]
public static bool step1(int instanceID, int line)
{
return false;
}
[UnityEditor.Callbacks.OnOpenAssetAttribute(2)]
public static bool step2(int instanceID, int line)
{
string strFilePath = AssetDatabase.GetAssetPath(EditorUtility.InstanceIDToObject(instanceID));
string strFileName = System.IO.Directory.GetParent(Application.dataPath) + "/" + strFilePath;
if (strFileName.EndsWith(".shader"))
{
string strSublimeTextPath = "D:/Program Files/Sublime Text 3";
if (strSublimeTextPath != null && strSublimeTextPath.Length > 0)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = strSublimeTextPath + (strSublimeTextPath.EndsWith("/") ? "" : "/") + "sublime_text.exe";
startInfo.Arguments = "\"" + strFileName + "\"";
process.StartInfo = startInfo;
process.Start();
//Debug.Log(startInfo.FileName + " \t " + startInfo.Arguments);
return true;
}
else
{
Debug.Log("Not Found Enviroment Variable 'SublimeText_Path'.");
return false;
}
}
return false;
}
}
總結
第6種方案是我目前正在使用的。沒有最好的工具,只有適合你的工具,可以都嘗試下。參考裏面也有把自己的寫的shader加入到一個庫中,這樣更方便。
附:參考
Shader着色器代碼輔助工具
Unity3D研究院之方便找和寫URP的shader
UPR Unlit Texture example