ShaderVariantCollection records which shader variants are actually used in each shader.

Inheritance: Object
 static void CollectShaderVariants()
 {
     var collection = new ShaderVariantCollection();
     var folders = new string[]{"Assets/Shaders"};
     var shaders = AssetDatabase.FindAssets("t:Shader", folders);
     foreach (var guid in shaders)
     {
         var path = AssetDatabase.GUIDToAssetPath(guid);
         var shader = AssetDatabase.LoadAssetAtPath<Shader>(path);
         var variant = new ShaderVariantCollection.ShaderVariant(shader, PassType.ForwardAdd, "DIRECTIONAL", "SHADOWS_OFF");
         collection.Add(variant);
     }
     AssetDatabase.CreateAsset(collection, "Assets/AutoGenerated.shadervariants");
 }
		private void DisplayAddVariantsMenu(Rect rect, Shader shader, ShaderVariantCollection collection)
		{
			ShaderVariantCollectionInspector.AddVariantMenuData addVariantMenuData = new ShaderVariantCollectionInspector.AddVariantMenuData();
			addVariantMenuData.shader = shader;
			addVariantMenuData.collection = collection;
			ShaderUtil.GetShaderVariantEntries(shader, collection, out addVariantMenuData.types, out addVariantMenuData.keywords);
			if (addVariantMenuData.keywords.Length == 0)
			{
				EditorApplication.Beep();
				return;
			}
			string[] array = new string[addVariantMenuData.keywords.Length];
			for (int i = 0; i < addVariantMenuData.keywords.Length; i++)
			{
				array[i] = (PassType)addVariantMenuData.types[i] + "/" + ((!string.IsNullOrEmpty(addVariantMenuData.keywords[i])) ? addVariantMenuData.keywords[i] : "<no keywords>");
			}
			EditorUtility.DisplayCustomMenu(rect, array, null, new EditorUtility.SelectMenuItemFunction(this.AddVariantMenuSelected), addVariantMenuData);
		}
 private void DisplayAddVariantsWindow(Shader shader, ShaderVariantCollection collection)
 {
   AddShaderVariantWindow.PopupData data = new AddShaderVariantWindow.PopupData();
   data.shader = shader;
   data.collection = collection;
   string[] keywords;
   ShaderUtil.GetShaderVariantEntries(shader, collection, out data.types, out keywords);
   if (keywords.Length == 0)
   {
     EditorApplication.Beep();
   }
   else
   {
     data.keywords = new string[keywords.Length][];
     for (int index = 0; index < keywords.Length; ++index)
       data.keywords[index] = keywords[index].Split(' ');
     AddShaderVariantWindow.ShowAddVariantWindow(data);
     GUIUtility.ExitGUI();
   }
 }
 private void DisplayAddVariantsMenu(Rect rect, Shader shader, ShaderVariantCollection collection)
 {
     AddVariantMenuData userData = new AddVariantMenuData {
         shader = shader,
         collection = collection
     };
     ShaderUtil.GetShaderVariantEntries(shader, collection, out userData.types, out userData.keywords);
     if (userData.keywords.Length == 0)
     {
         EditorApplication.Beep();
     }
     else
     {
         string[] options = new string[userData.keywords.Length];
         for (int i = 0; i < userData.keywords.Length; i++)
         {
             options[i] = ((PassType) userData.types[i]) + "/" + (!string.IsNullOrEmpty(userData.keywords[i]) ? userData.keywords[i] : "<no keywords>");
         }
         EditorUtility.DisplayCustomMenu(rect, options, null, new EditorUtility.SelectMenuItemFunction(this.AddVariantMenuSelected), userData);
     }
 }
 private void DisplayAddVariantsWindow(Shader shader, ShaderVariantCollection collection)
 {
     string[] strArray;
     AddShaderVariantWindow.PopupData data = new AddShaderVariantWindow.PopupData {
         shader = shader,
         collection = collection
     };
     ShaderUtil.GetShaderVariantEntries(shader, collection, out data.types, out strArray);
     if (strArray.Length == 0)
     {
         EditorApplication.Beep();
     }
     else
     {
         data.keywords = new string[strArray.Length][];
         for (int i = 0; i < strArray.Length; i++)
         {
             char[] separator = new char[] { ' ' };
             data.keywords[i] = strArray[i].Split(separator);
         }
         AddShaderVariantWindow.ShowAddVariantWindow(data);
         GUIUtility.ExitGUI();
     }
 }
Ejemplo n.º 6
0
 internal static extern void GetShaderVariantEntries(Shader shader, ShaderVariantCollection skipAlreadyInCollection, out int[] types, out string[] keywords);
Ejemplo n.º 7
0
 internal static extern bool AddNewShaderToCollection(Shader shader, ShaderVariantCollection collection);
Ejemplo n.º 8
0
 private static extern void Internal_Create([Writable] ShaderVariantCollection mono);
Ejemplo n.º 9
0
 /// <summary>
 ///   <para>Create a new empty shader variant collection.</para>
 /// </summary>
 public ShaderVariantCollection()
 {
     ShaderVariantCollection.Internal_Create(this);
 }
Ejemplo n.º 10
0
 private static void Internal_Create([Writable] ShaderVariantCollection mono)
 {
     throw new NotImplementedException("なにこれ");
 }
		public bool Contains(ShaderVariantCollection.ShaderVariant variant)
		{
			return this.ContainsInternal(variant.shader, variant.passType, variant.keywords);
		}
		public bool Remove(ShaderVariantCollection.ShaderVariant variant)
		{
			return this.RemoveInternal(variant.shader, variant.passType, variant.keywords);
		}
    static int _CreateShaderVariantCollection(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            ShaderVariantCollection obj = new ShaderVariantCollection();
            LuaScriptMgr.Push(L, obj);
            return 1;
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: ShaderVariantCollection.New");
        }

        return 0;
    }