Skip to content

Commit

Permalink
Merge branch 'head_unity2019'
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteflare committed Jun 14, 2022
2 parents c69c64a + 9e5a777 commit 3bc2469
Show file tree
Hide file tree
Showing 116 changed files with 3,292 additions and 2,022 deletions.
4 changes: 4 additions & 0 deletions Editor/WFEditorSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class WFEditorSetting : ScriptableObject
public bool stripFallback = true;
public bool stripMetaPass = true;
public bool stripUnusedLodFade = true;
public bool validateSceneMaterials = true;

[Header("Editor Behaviour Settings")]
public bool enableScanProjects = true;
Expand Down Expand Up @@ -78,6 +79,7 @@ public class WFEditorSettingEditor : Editor
SerializedProperty p_stripFallback;
SerializedProperty p_stripMetaPass;
SerializedProperty p_stripUnusedLodFade;
SerializedProperty p_validateSceneMaterials;
SerializedProperty p_enableScanProjects;

private void OnEnable()
Expand All @@ -88,6 +90,7 @@ private void OnEnable()
this.p_stripUnusedLodFade = serializedObject.FindProperty(nameof(WFEditorSetting.stripUnusedLodFade));
this.p_stripFallback = serializedObject.FindProperty(nameof(WFEditorSetting.stripFallback));
this.p_stripMetaPass = serializedObject.FindProperty(nameof(WFEditorSetting.stripMetaPass));
this.p_validateSceneMaterials = serializedObject.FindProperty(nameof(WFEditorSetting.validateSceneMaterials));
this.p_enableScanProjects = serializedObject.FindProperty(nameof(WFEditorSetting.enableScanProjects));
}

Expand All @@ -111,6 +114,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(p_stripFallback);
EditorGUILayout.PropertyField(p_stripMetaPass);
}
EditorGUILayout.PropertyField(p_validateSceneMaterials);

// Editor Behaviour Settings

Expand Down
3 changes: 2 additions & 1 deletion Editor/WFEditorSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ MonoBehaviour:
stripUnusedVariant: 1
stripFallback: 1
stripMetaPass: 1
stripLodCrossFade: 1
stripUnusedLodFade: 1
validateSceneMaterials: 1
enableScanProjects: 1
2 changes: 1 addition & 1 deletion Editor/WFMaterialTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void ApplyToMaterial(IEnumerable<Material> mats)
if (mat.shader != material.shader)
{
mat.shader = material.shader;
mat.renderQueue = material.renderQueue;
mat.renderQueue = WFCommonUtility.GetMaterialRenderQueueValue(material);
}
}

Expand Down
16 changes: 8 additions & 8 deletions Editor/WF_AutoMigrationPostprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#if UNITY_EDITOR

using System.Linq;
using UnityEditor;

namespace UnlitWF
Expand All @@ -25,14 +26,13 @@ public class WF_AutoMigrationPostprocessor : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath)
{
ScanAndMigrationExecutor.Migration(importedAssets);
}

[InitializeOnLoadMethod]
public static void ExecuteAuto()
{
ScanAndMigrationExecutor.ExecuteAuto();

// マテリアルのマイグレーション
Converter.ScanAndMigrationExecutor.Migration(importedAssets);
// もしshaderファイルがimportされたなら、そのタイミングで全スキャンも動作させる
if (importedAssets.Any(path => path != null && path.EndsWith(".shader", System.StringComparison.InvariantCultureIgnoreCase)))
{
Converter.ScanAndMigrationExecutor.ExecuteAuto();
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions Editor/WF_Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ public static bool IsMobileSupportedShader(Material mat)
return mat != null && IsMobileSupportedShader(mat.shader);
}

public static bool IsMigrationRequiredMaterial(Material mat)
{
return mat != null && Converter.WFMaterialMigrationConverter.ExistsNeedsMigration(mat);
}

/// <summary>
/// 最新リリースのVersionInfo
/// </summary>
Expand Down Expand Up @@ -460,6 +465,19 @@ public static string GetShaderFallBackTarget(Material mat)
{
return mat == null ? null : GetShaderFallBackTarget(mat.shader);
}

public static int GetMaterialRenderQueueValue(Material mat)
{
// Material.renderQueue の値を単に参照すると -1 (FromShader) が取れないので SerializedObject から取得する
var so = new SerializedObject(mat);
so.Update();
var prop = so.FindProperty("m_CustomRenderQueue");
if (prop != null)
{
return prop.intValue;
}
return mat.renderQueue;
}
}

public abstract class WFCustomKeywordSetting
Expand Down
Loading

0 comments on commit 3bc2469

Please sign in to comment.