Initial commit

This commit is contained in:
msk
2022-01-22 20:13:49 -08:00
parent f9d23e5bcf
commit 687473573d
878 changed files with 70957 additions and 0 deletions
@@ -0,0 +1,61 @@
// Alloy Physical Shader Framework
// Copyright 2013-2017 RUST LLC.
// http://www.alloy.rustltd.com/
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
public static class AlloyEditor {
public static void DrawAddTabGUI(List<AlloyTabAdd> tabsToAdd) {
if (tabsToAdd.Count <= 0) {
return;
}
GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
GUILayout.Label("");
var rect = GUILayoutUtility.GetLastRect();
rect.x -= 35.0f;
rect.width += 10.0f;
GUI.color = Color.clear;
bool add = GUI.Button(rect, new GUIContent(""), "Box");
GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
Rect subRect = rect;
foreach (var tab in tabsToAdd) {
GUI.color = tab.Color;
GUI.Box(subRect, "", "ShurikenModuleTitle");
subRect.x += rect.width / tabsToAdd.Count;
subRect.width -= rect.width / tabsToAdd.Count;
}
GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
var delRect = rect;
delRect.xMin = rect.xMax;
delRect.xMax += 40.0f;
if (GUI.Button(delRect, "", "ShurikenModuleTitle") || add) {
var menu = new GenericMenu();
foreach (var tab in tabsToAdd) {
menu.AddItem(new GUIContent(tab.Name), false, tab.Enable);
}
menu.ShowAsContext();
}
delRect.x += 10.0f;
GUI.Label(delRect, "+");
rect.x += EditorGUIUtility.currentViewWidth / 2.0f - 30.0f;
// Ensures tab text is always white, even when using light skin in pro.
GUI.color = EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.9f, 0.9f, 0.9f);
GUI.Label(rect, "Add tab", EditorStyles.whiteLabel);
GUI.color = Color.white;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dd3f45d6cfc037e43baa01683c2ead46
timeCreated: 1447518555
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
// Alloy Physical Shader Framework
// Copyright 2013-2017 RUST LLC.
// http://www.alloy.rustltd.com/
using UnityEditor;
using UnityEngine;
public static class AlloyMenuGroups {
[MenuItem(AlloyUtils.MenuItem + "Documentation", false, 100)]
static void Documentation() {
Application.OpenURL("https://alloy.rustltd.com/documentation");
}
[MenuItem(AlloyUtils.MenuItem + "Samples", false, 100)]
static void Samples() {
Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/content/43687");
}
[MenuItem(AlloyUtils.MenuItem + "Contact", false, 100)]
static void Contact() {
Application.OpenURL("https://alloy.rustltd.com/contact");
}
[MenuItem(AlloyUtils.MenuItem + "About", false, 100)]
static void About() {
Application.OpenURL("https://alloy.rustltd.com/");
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 85976895d5de5ee4f914e54f4aae9905
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
@@ -0,0 +1,289 @@
// Alloy Physical Shader Framework
// Copyright 2013-2017 RUST LLC.
// http://www.alloy.rustltd.com/
using System.Collections.Generic;
using System.Linq;
using System.IO;
using UnityEditor;
using UnityEngine;
public static class AlloyMigrationTools {
#if H3VR_IMPORTED
private const string keywordReportFilename = "/Alloy/Scripts/Material Report.txt";
[MenuItem(AlloyUtils.MenuItem + "Material Report", false, 11)]
private static void MaterialReport() {
var fileName = Application.dataPath + keywordReportFilename;
var sr = File.CreateText(fileName);
var materials = GetSceneMaterialsWithKeywords().OrderBy(m => m.name);
var keywordList = materials
.SelectMany(m => m.shaderKeywords)
.Where(k => !string.IsNullOrEmpty(k))
.Distinct()
.OrderBy(k => k);
var keywordCount = keywordList.Count();
var materialShaderNames = new List<string>();
sr.WriteLine(" ");
sr.WriteLine("-----------------------------------------------------------------------");
sr.WriteLine(" Keywords: " + keywordCount);
sr.WriteLine("-----------------------------------------------------------------------");
foreach (var keyword in keywordList) {
sr.WriteLine("\"" + keyword + "\",");
}
sr.WriteLine(" ");
sr.WriteLine("-----------------------------------------------------------------------");
sr.WriteLine(" Keywords -> Materials: " + keywordCount);
sr.WriteLine("-----------------------------------------------------------------------");
foreach (var keyword in keywordList) {
sr.WriteLine("\"" + keyword + "\",");
foreach (var material in materials) {
var shaderKeywords = material.shaderKeywords;
if (shaderKeywords.Contains(keyword)) {
sr.WriteLine(" " + material.name);
}
}
sr.WriteLine(" ");
}
sr.WriteLine("-----------------------------------------------------------------------");
sr.WriteLine(" Materials -> Keywords: " + materials.Count());
sr.WriteLine("-----------------------------------------------------------------------");
foreach (var material in materials) {
var shaderKeywords = material.shaderKeywords.OrderBy(k => k);
sr.WriteLine(material.name);
foreach (var keyword in shaderKeywords) {
if (!string.IsNullOrEmpty(keyword)) {
sr.WriteLine(" \"" + keyword + "\",");
}
}
sr.WriteLine(" ");
materialShaderNames.Add(material.shader.name);
}
var shaderNames = materialShaderNames.Distinct().OrderBy(s => s);
sr.WriteLine("-----------------------------------------------------------------------");
sr.WriteLine(" Shaders -> Materials: " + shaderNames.Count());
sr.WriteLine("-----------------------------------------------------------------------");
foreach (var shaderName in shaderNames) {
var shaderMaterials = materials.Where(m => m.shader.name == shaderName).Select(m => m.name);
sr.WriteLine("\"" + shaderName + "\"");
foreach (var materialName in shaderMaterials) {
if (!string.IsNullOrEmpty(materialName)) {
sr.WriteLine(" " + materialName);
}
}
sr.WriteLine(" ");
}
sr.Close();
System.Diagnostics.Process.Start(fileName);
}
// [MenuItem(AlloyUtils.MenuItem + "Material Migrator", false, 11)]
// private static void MaterialMigrator() {
// var window = ScriptableObject.CreateInstance<AlloyMaterialMigratorPopup>();
// var dimensions = new Vector2(350, 100);
//
// window.position = new Rect(Screen.width / 2, Screen.height / 2, 0, 0);
// window.minSize = dimensions;
// window.maxSize = dimensions;
// window.ShowUtility();
// }
[MenuItem(AlloyUtils.MenuItem + "Light Converter", false, 11)]
private static void LightConverter() {
var lights = Resources.FindObjectsOfTypeAll<Light>();
var lightsLength = lights.Length;
for (int i = 0; i < lightsLength; i++) {
var light = lights[i];
EditorUtility.DisplayProgressBar(
"Converting lights...",
string.Format("Light {0} / {1}.", i + 1, lightsLength),
i / (lightsLength - 1.0f));
// Skip Unity baked Area Lights & Prefabs.
if (light.type != LightType.Area
&& !EditorUtility.IsPersistent(light)) {
var area = light.GetComponent<AlloyAreaLight>();
if (area == null) {
Undo.RecordObject(light.gameObject, "Convert to Alloy area lights.");
area = Undo.AddComponent<AlloyAreaLight>(light.gameObject);
}
Undo.RecordObject(light, "Set default light cookie");
area.UpdateBinding();
}
}
EditorUtility.ClearProgressBar();
}
private static IEnumerable<Material> GetSceneMaterialsWithKeywords() {
return Resources.FindObjectsOfTypeAll<Material>().Where(m => m.shaderKeywords.Length > 0);
}
}
public class AlloyMaterialMigratorPopup : EditorWindow {
private const string messageFilename = "/Alloy/Scripts/Editor/MaterialMigratorWarning.txt";
private static string[] keywordsToRemove = new string[] {
"_AO2MAPUV_UV0",
"_AO2MAPUV_UV1",
"_BLENDMAPUV_UV0",
"_BLENDMAPUV_UV1",
"_BUMPMODE_BUMP",
"_BUMPMODE_PARALLAX", // Set by stupid KeywordEnum.
"_BUMPMODE_SPOM",
"_CARFLAKEMAPUV_UV0",
"_CARFLAKEMAPUV_UV1",
"_DECAL_OFF",
"_DECALMODE_NONE",
"_DECALTEXUV_UV0",
"_DECALTEXUV_UV1",
"_DETAIL_ON", // Replaced with _DETAIL_MULX2
"_DETAILALBEDOMAPUV_UV0",
"_DETAILALBEDOMAPUV_UV1",
"_DETAILMASKSSOURCE_TEXTURE", // From when I was trying that Masks channel picker idea. >_<
"_DETAILMASKSOURCE_TEXTURE", // Discarded first attempt at name.
"_DETAILMASKSOURCE_TEXTUREALPHA", // Set by stupid KeywordEnum.
"_DETAILMASKSOURCE_VERTEXCOLORALPHA", // Replaced with _NORMALMAP
"_DETAILMODE_MUL",
"_DETAILMODE_MULX2",
"_DIRECTIONALBLENDMODE_OBJECT", // Set by stupid KeywordEnum.
"_DISSOLVETEXUV_UV0",
"_DISSOLVETEXUV_UV1",
"_EMISSION_ON",
"_ENVIRONMENTMAPMODE_RSRM",
"_ENVIRONMENTMAPMODE_SKYSHOP",
"_ENVIRONMENTMAPMODE_SKYSHOPSH",
"_INCANDESCENCEMAPUV_UV0",
"_INCANDESCENCEMAPUV_UV1",
"_INCANDESCENCEMAPUV2_UV0",
"_INCANDESCENCEMAPUV2_UV1",
"_MAINTEXTURESMODE_FULL",
"_MAINTEXTURESMODE_LITE",
"_MAINTEXTURESROUGHNESSSOURCE_BASECOLORALPHA", // Discarded first attempt at name.
"_MAINTEXTURESROUGHNESSSOURCE_MATERIALALPHA", // Discarded first attempt at name.
"_MAINROUGHNESSSOURCE_BASECOLORALPHA", // Replaced with _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
"_MAINROUGHNESSSOURCE_PACKEDMAPALPHA", // Set by stupid KeywordEnum.
"_ORIENTEDROUGHNESSSOURCE_BASECOLORALPHA", // Replaced with _SPECGLOSSMAP
"_ORIENTEDROUGHNESSSOURCE_PACKEDMAPALPHA", // Set by stupid KeywordEnum.
"_ORIENTEDTEXTURESMODE_FULL",
"_ORIENTEDTEXTURESMODE_LITE",
"_ORIENTEDTEXTURESROUGHNESSSOURCE_BASECOLORALPHA", // Discarded first attempt at name.
"_ORIENTEDTEXTURESROUGHNESSSOURCE_MATERIALALPHA", // Discarded first attempt at name.
"_PARALLAX_ON", // Replaced with _PARALLAXMAP
"_RIMTEXUV_UV0",
"_RIMTEXUV_UV1",
"_RIMTEXUV2_UV0",
"_RIMTEXUV2_UV1",
"_SECONDARYROUGHNESSSOURCE_BASECOLORALPHA", // Replaced with _METALLICGLOSSMAP
"_SECONDARYROUGHNESSSOURCE_PACKEDMAPALPHA", // Set by stupid KeywordEnum.
"_SECONDARYTEXTURESMODE_FULL",
"_SECONDARYTEXTURESMODE_LITE",
"_TESSELLATIONMODE_COMBINED", // Dropped this mode in favor of using two other modes keywords together.
"_TRANSITIONTEXUV_UV0",
"_TRANSITIONTEXUV_UV1",
"_TRIPLANARMODE_OBJECT", // Set by stupid KeywordEnum.
"_UVSEC_UV0", // Standard shader sets this.
"_UVSEC_UV1", // Standard shader sets this.
};
void OnGUI() {
var message = File.ReadAllText(Application.dataPath + messageFilename);
titleContent = new GUIContent("Migrate Materials?");
EditorGUILayout.LabelField(message, EditorStyles.wordWrappedLabel);
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Confirm")) {
Close();
MigrateMaterials();
}
if (GUILayout.Button("Cancel")) {
Close();
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
void MigrateMaterials() {
try {
var materialGuids = AssetDatabase.FindAssets("t:material");
var length = materialGuids.Length;
for (int i = 0; i < length; i++) {
var material = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(materialGuids[i]), typeof(Material)) as Material;
var toRemove = material.shaderKeywords.Intersect(keywordsToRemove);
var shaderName = material.shader.name;
EditorUtility.DisplayProgressBar(
"Migrating Materials...",
string.Format("({0} / {1}) {2}", i, length, material.name),
i / (float)(length - 1));
if (shaderName.Contains("Alloy")) {
if (material.HasProperty("_HasBumpMap")
&& Mathf.Approximately(material.GetFloat("_HasBumpMap"), 1.0f)) {
material.EnableKeyword("EFFECT_BUMP");
}
foreach (var keyword in toRemove) {
if (!string.IsNullOrEmpty(keyword)) {
material.DisableKeyword(keyword);
// Migrate to Unity keywords.
switch (keyword) {
case "_DETAIL_ON":
material.EnableKeyword("_DETAIL_MULX2");
break;
case "_DETAILMASKSOURCE_VERTEXCOLORALPHA":
material.EnableKeyword("_NORMALMAP");
break;
case "_MAINROUGHNESSSOURCE_BASECOLORALPHA":
material.EnableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A");
break;
case "_PARALLAX_ON":
material.EnableKeyword("_PARALLAXMAP");
break;
}
}
}
EditorUtility.SetDirty(material);
AssetDatabase.SaveAssets();
material = null;
EditorUtility.UnloadUnusedAssetsImmediate();
}
}
}
finally {
EditorUtility.ClearProgressBar();
}
}
#endif
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 222acbd1878d5b3459b1f2946805fba9
timeCreated: 1425000426
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,51 @@
// Alloy Physical Shader Framework
// Copyright 2013-2017 RUST LLC.
// http://www.alloy.rustltd.com/
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(MinValueAttribute))]
public class MinValueDrawer : PropertyDrawer {
// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
// Using BeginProperty / EndProperty on the parent property means that
// prefab override logic works on the entire property.
EditorGUI.BeginProperty(position, label, property);
// Draw label
EditorGUI.BeginChangeCheck();
float newVal = EditorGUI.FloatField(position, label, property.floatValue);
if (EditorGUI.EndChangeCheck()) {
newVal = Mathf.Max((attribute as MinValueAttribute).Min, newVal);
property.floatValue = newVal;
}
EditorGUI.EndProperty();
}
}
[CustomPropertyDrawer(typeof(MaxValueAttribute))]
public class MaxValueDrawer : PropertyDrawer {
// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
// Using BeginProperty / EndProperty on the parent property means that
// prefab override logic works on the entire property.
EditorGUI.BeginProperty(position, label, property);
// Draw label
EditorGUI.BeginChangeCheck();
float newVal = EditorGUI.FloatField(position, label, property.floatValue);
if (EditorGUI.EndChangeCheck()) {
newVal = Mathf.Min((attribute as MaxValueAttribute).Max, newVal);
property.floatValue = newVal;
}
EditorGUI.EndProperty();
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cd608910999af3a4e960e52f543102ed
timeCreated: 1445390480
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,54 @@
// Alloy Physical Shader Framework
// Copyright 2013-2017 RUST LLC.
// http://www.alloy.rustltd.com/
using System.IO;
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
static class AlloyRequiredActions {
static AlloyRequiredActions() {
// Check if popup hasn't appeared for this version.
if (File.Exists(AlloyRequiredActionsPopup.MessageFilePath)
&& EditorPrefs.GetString(AlloyRequiredActionsPopup.SettingsKey) != AlloyUtils.Version) {
var window = ScriptableObject.CreateInstance<AlloyRequiredActionsPopup>();
var dimensions = new Vector2(350, 200);
window.position = new Rect(Screen.width / 2, Screen.height / 2, 0, 0);
window.minSize = dimensions;
window.maxSize = dimensions;
window.ShowUtility();
}
}
}
public class AlloyRequiredActionsPopup : EditorWindow {
public const string SettingsKey = "AlloyRequiredActionsPopupShown";
public static string MessageFilePath {
get { return AlloyUtils.AssetsPath + "REQUIRED ACTIONS.txt"; }
}
void OnGUI() {
var message = File.ReadAllText(MessageFilePath);
titleContent = new GUIContent(string.Format("Required Actions for Alloy {0}...", AlloyUtils.Version));
EditorGUILayout.LabelField(message, EditorStyles.wordWrappedLabel);
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Okay")) {
Close();
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
// Make sure it doesn't reappear again for this version.
EditorPrefs.SetString(SettingsKey, AlloyUtils.Version);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c605d19298efffc45afeb01a1a5086fa
timeCreated: 1473702994
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
We STRONGLY recommend that you save and back up your work before proceeding.
Do you wish to continue?
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e579897034a773341b981f6cb2ab54c6
timeCreated: 1474115145
licenseType: Pro
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant: