summaryrefslogtreecommitdiff
path: root/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers
diff options
context:
space:
mode:
authortylermurphy534 <tylermurphy534@gmail.com>2022-11-06 15:12:42 -0500
committertylermurphy534 <tylermurphy534@gmail.com>2022-11-06 15:12:42 -0500
commiteb84bb298d2b95aec7b2ae12cbf25ac64f25379a (patch)
treeefd616a157df06ab661c6d56651853431ac6b08b /VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers
downloadunityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.gz
unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.bz2
unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.zip
move to self host
Diffstat (limited to 'VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers')
-rw-r--r--VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs31
-rw-r--r--VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs.meta8
-rw-r--r--VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs65
-rw-r--r--VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs.meta11
-rw-r--r--VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs82
-rw-r--r--VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs.meta11
6 files changed, 208 insertions, 0 deletions
diff --git a/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs
new file mode 100644
index 00000000..72ddab56
--- /dev/null
+++ b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs
@@ -0,0 +1,31 @@
+using UnityEditor;
+using UnityEngine;
+using DigitalOpus.MB.Core;
+
+namespace DigitalOpus.MB.MBEditor
+{
+ [CustomPropertyDrawer(typeof(ShaderTextureProperty))]
+ public class MB3_ShaderTexturePropertyDrawer : PropertyDrawer
+ {
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ label = EditorGUI.BeginProperty(position, label, property);
+ Rect contentPosition = EditorGUI.PrefixLabel(position, label);
+ if (position.height > 16f)
+ {
+ position.height = 16f;
+ EditorGUI.indentLevel += 1;
+ contentPosition = EditorGUI.IndentedRect(position);
+ contentPosition.y += 18f;
+ }
+ contentPosition.width *= 0.75f;
+ EditorGUI.indentLevel = 0;
+ EditorGUI.PropertyField(contentPosition, property.FindPropertyRelative("name"), GUIContent.none);
+ contentPosition.x += contentPosition.width;
+ contentPosition.width /= 3f;
+ EditorGUIUtility.labelWidth = 50f;
+ EditorGUI.PropertyField(contentPosition, property.FindPropertyRelative("isNormalMap"), new GUIContent("isBump"));
+ EditorGUI.EndProperty();
+ }
+ }
+}
diff --git a/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs.meta b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs.meta
new file mode 100644
index 00000000..54705e92
--- /dev/null
+++ b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB3_ShaderTexturePropertyDrawer.cs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 24ced5fa006456249ac31e87abe5aa5b
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
diff --git a/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs
new file mode 100644
index 00000000..b20869d9
--- /dev/null
+++ b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs
@@ -0,0 +1,65 @@
+using UnityEditor;
+using UnityEngine;
+using DigitalOpus.MB.Core;
+
+namespace DigitalOpus.MB.MBEditor
+{
+ public class MB_ConvertTextureArrayFormatWizard : ScriptableWizard
+ {
+ public Texture2DArray textureArray;
+ public TextureFormat format = TextureFormat.ARGB32;
+
+ [MenuItem("Window/Mesh Baker/TextureArray Format Converter")]
+ static void CreateWizard()
+ {
+ ScriptableWizard.DisplayWizard<MB_ConvertTextureArrayFormatWizard>("Convert Texture Array Format", "Close", "Convert");
+ }
+
+ void OnWizardCreate()
+ {
+
+ }
+
+ void OnWizardUpdate()
+ {
+ helpString = "Please assign a texture array";
+ }
+
+ void OnWizardOtherButton()
+ {
+ helpString = "";
+ if (textureArray == null)
+ {
+ helpString = "Please assign a texture array";
+ return;
+ }
+
+ MB3_EditorMethods editorMethods = new MB3_EditorMethods();
+ if (!editorMethods.TextureImporterFormatExistsForTextureFormat(format))
+ {
+ helpString = "No ImporterFormat exists for the selected format. Please select a different format.";
+ return;
+ }
+
+ if (textureArray.format != TextureFormat.ARGB32 &&
+ textureArray.format != TextureFormat.RGB24)
+ {
+ helpString = "Source TextureArray must be in format ARGB32 or RGB24. This will probably be changed in" +
+ "a future version of Mesh Baker.";
+ return;
+ }
+
+ Texture2DArray outArray = new Texture2DArray(textureArray.width, textureArray.height, textureArray.depth, format, true);
+ if (editorMethods.ConvertTexture2DArray(textureArray, outArray, format))
+ {
+ string pth = UnityEditor.AssetDatabase.GetAssetPath(textureArray);
+ if (pth == null) pth = "Assets/TextureArray.asset";
+ pth = pth.Replace(".asset", "");
+ pth += format.ToString() + ".asset";
+ UnityEditor.AssetDatabase.CreateAsset(outArray, pth);
+ Debug.Log("Convert success saved asset: " + pth);
+ }
+ }
+ }
+}
+
diff --git a/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs.meta b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs.meta
new file mode 100644
index 00000000..5603530c
--- /dev/null
+++ b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_ConvertTextureArrayFormatWizard.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d355da520c795f543a934da176eb59ca
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs
new file mode 100644
index 00000000..3c1d9978
--- /dev/null
+++ b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs
@@ -0,0 +1,82 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+using DigitalOpus.MB.MBEditor;
+
+namespace DigitalOpus.MB.MBEditor
+{
+ /// <summary>
+ /// Draws rows for the PrafabPairs in the Switch Prefabs In Scene Window.
+ /// </summary>
+ [CustomPropertyDrawer(typeof(MB_ReplacePrefabsSettings.PrefabPair))]
+ public class MB_PrefabPairPropertyDrawer : PropertyDrawer
+ {
+ private GUIStyle redFont = new GUIStyle();
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ EditorGUI.BeginProperty(position, label, property);
+ position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
+ int indent = EditorGUI.indentLevel;
+ EditorGUI.indentLevel = 0;
+
+ float xx = position.x;
+ float yy = position.y;
+ float ww = 15f;
+ float hh = position.height;
+
+ Rect enabledRect = new Rect(xx, yy, ww, EditorGUIUtility.singleLineHeight);
+ xx += ww;
+ ww = 50;
+ Rect srcLabel = new Rect(xx, yy, ww, EditorGUIUtility.singleLineHeight);
+ xx += ww;
+ ww = 200;
+ Rect sourceRect = new Rect(xx, yy, ww, EditorGUIUtility.singleLineHeight);
+ xx += ww;
+ ww = 50;
+ Rect targetLabel = new Rect(xx, yy, ww, EditorGUIUtility.singleLineHeight);
+ xx += ww;
+ ww = 200;
+ Rect targetRect = new Rect(xx, yy, ww, EditorGUIUtility.singleLineHeight);
+
+ EditorGUI.PropertyField(enabledRect, property.FindPropertyRelative("enabled"), GUIContent.none);
+ EditorGUI.LabelField(srcLabel, "Source:");
+ EditorGUI.PropertyField(sourceRect, property.FindPropertyRelative("srcPrefab"), GUIContent.none);
+ EditorGUI.LabelField(targetLabel, "Target:");
+ EditorGUI.PropertyField(targetRect, property.FindPropertyRelative("targPrefab"), GUIContent.none);
+
+ SerializedProperty errorsProp = property.serializedObject.FindProperty(property.propertyPath + ".objsWithErrors");
+ if (errorsProp.arraySize > 0)
+ {
+ redFont.normal.textColor = Color.red;
+ for (int i = 0; i < errorsProp.arraySize; i++)
+ {
+ xx = position.x;
+ yy = position.y + (1 + i) * EditorGUIUtility.singleLineHeight;
+ ww = 100;
+ SerializedProperty errProp = errorsProp.GetArrayElementAtIndex(i);
+ GameObject obj = (GameObject)errProp.FindPropertyRelative("errorObj").objectReferenceValue;
+ string errStr = errProp.FindPropertyRelative("error").stringValue;
+ Rect buttonRect = new Rect(xx, yy, ww, EditorGUIUtility.singleLineHeight);
+ if (GUI.Button(buttonRect, "Select"))
+ {
+ if (obj != null) Selection.activeGameObject = obj;
+ }
+ xx += ww;
+ ww = 500;
+ EditorGUI.LabelField(new Rect(xx, yy, ww, EditorGUIUtility.singleLineHeight), errStr, redFont);
+ }
+ }
+
+ EditorGUI.indentLevel = indent;
+ EditorGUI.EndProperty();
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ SerializedProperty errorsProp = property.serializedObject.FindProperty(property.propertyPath + ".objsWithErrors");
+ return base.GetPropertyHeight(property, label) + errorsProp.arraySize * EditorGUIUtility.singleLineHeight;
+ }
+ }
+}
diff --git a/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs.meta b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs.meta
new file mode 100644
index 00000000..741dc8a6
--- /dev/null
+++ b/VRCSDK3Worlds/Assets/MeshBaker/Editor/propertyDrawers/MB_PrefabPairPropertyDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f8fdae7bfb5aa3a41ab365cd5a8238c8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: