updated with enemy
This commit is contained in:
@ -0,0 +1,61 @@
|
||||
using Adobe.Substance;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawer
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty property, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
switch (content.Description.Type)
|
||||
{
|
||||
case SubstanceValueType.Float:
|
||||
return SubstanceInputDrawerFloat.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.Float2:
|
||||
return SubstanceInputDrawerFloat2.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.Float3:
|
||||
return SubstanceInputDrawerFloat3.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.Float4:
|
||||
return SubstanceInputDrawerFloat4.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.Int:
|
||||
return SubstanceInputDrawerInt.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.Int2:
|
||||
return SubstanceInputDrawerInt2.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.Int3:
|
||||
return SubstanceInputDrawerInt3.DrawInput(content.DataProp, content, handler, inputID); ;
|
||||
|
||||
case SubstanceValueType.Int4:
|
||||
return SubstanceInputDrawerInt4.DrawInput(property, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.Image:
|
||||
return SubstanceInputDrawerTexture.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
case SubstanceValueType.String:
|
||||
return SubstanceInputDrawerString.DrawInput(content.DataProp, content, handler, inputID);
|
||||
|
||||
default:
|
||||
return DrawDefault(property, content);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content)
|
||||
{
|
||||
if (content.Description.WidgetType == SubstanceWidgetType.NoWidget)
|
||||
{
|
||||
EditorGUILayout.LabelField($"Hidden property.");
|
||||
return false;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.LabelField($"Not supported. Value with widget {content.Description.WidgetType}");
|
||||
EditorGUI.indentLevel--;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 291115c592a8ea648812908d840ceb8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,67 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerFloat
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
float newValue;
|
||||
bool changed = false;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
case SubstanceWidgetType.Slider:
|
||||
changed = DrawSlider(valueProperty, content as SubstanceFloatGUIContent, out newValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content, out newValue);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputFloat(inputID, newValue);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool DrawSlider(SerializedProperty valueProperty, SubstanceFloatGUIContent content, out float newValue)
|
||||
{
|
||||
var floatInputDesc = content.NumericalDescription;
|
||||
|
||||
var maxValue = floatInputDesc.MaxValue;
|
||||
var minValue = floatInputDesc.MinValue;
|
||||
var sliderClamp = maxValue != minValue;
|
||||
|
||||
var oldValue = valueProperty.floatValue;
|
||||
|
||||
newValue = EditorGUILayout.Slider(content, oldValue, sliderClamp ? minValue : 0, sliderClamp ? maxValue : 50);
|
||||
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
valueProperty.floatValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out float newValue)
|
||||
{
|
||||
var oldValue = valueProperty.floatValue;
|
||||
newValue = EditorGUILayout.FloatField(content, oldValue);
|
||||
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
valueProperty.floatValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 033dbc14304ac024da91e3803dfab82f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,43 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerFloat2
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
Vector2 newValue;
|
||||
bool changed;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content, out newValue);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputFloat2(inputID, newValue);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector2 newValue)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
var previewValue = valueProperty.vector2Value;
|
||||
newValue = EditorGUILayout.Vector2Field(content, previewValue);
|
||||
|
||||
if (newValue != previewValue)
|
||||
{
|
||||
valueProperty.vector2Value = newValue;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a184eff873fa9f04a9cb3c6e7a45656c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,70 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerFloat3
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
Vector3 newValue;
|
||||
bool changed;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
case SubstanceWidgetType.Color:
|
||||
changed = DrawColorPicker(valueProperty, content, out newValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content, out newValue);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputFloat3(inputID, newValue);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders custome GUI for input float3 as color.
|
||||
/// </summary>
|
||||
/// <param name="position">GUI position rect.</param>
|
||||
/// <param name="valueProperty">Value property.</param>
|
||||
/// <param name="content">GUI content.</param>
|
||||
/// <param name="description">Description for the target input.</param>
|
||||
private static bool DrawColorPicker(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector3 newValue)
|
||||
{
|
||||
var previewValue = valueProperty.vector3Value;
|
||||
|
||||
var color = new Color(previewValue.x, previewValue.y, previewValue.z, 1);
|
||||
var newColor = EditorGUILayout.ColorField(content, color, false, false, false);
|
||||
newValue = new Vector3();
|
||||
|
||||
if (color != newColor)
|
||||
{
|
||||
newValue = new Vector4(newColor.r, newColor.g, newColor.b, newColor.a);
|
||||
valueProperty.vector3Value = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector3 newValue)
|
||||
{
|
||||
var previewValue = valueProperty.vector3Value;
|
||||
newValue = EditorGUILayout.Vector3Field(content, previewValue);
|
||||
|
||||
if (newValue != previewValue)
|
||||
{
|
||||
valueProperty.vector3Value = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd7292cd00c740040b07a24e3f49ac8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,68 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerFloat4
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
Vector4 newValyue;
|
||||
bool changed;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
case SubstanceWidgetType.Color:
|
||||
changed = DrawColorPicker(valueProperty, content, out newValyue);
|
||||
break;
|
||||
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content, out newValyue);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputFloat4(inputID, newValyue);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders custome GUI for input float4 as color.
|
||||
/// </summary>
|
||||
/// <param name="position">GUI position rect.</param>
|
||||
/// <param name="valueProperty">Value property.</param>
|
||||
/// <param name="content">GUI content.</param>
|
||||
/// <param name="description">Description for the target input.</param>
|
||||
private static bool DrawColorPicker(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector4 newValue)
|
||||
{
|
||||
var previewValue = valueProperty.vector4Value;
|
||||
|
||||
var color = new Vector4(previewValue.x, previewValue.y, previewValue.z, previewValue.w);
|
||||
newValue = EditorGUILayout.ColorField(content, color);
|
||||
|
||||
if (color != newValue)
|
||||
{
|
||||
valueProperty.vector4Value = new Vector4(newValue.x, newValue.y, newValue.z, newValue.w);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector4 newValue)
|
||||
{
|
||||
var oldValue = valueProperty.vector4Value;
|
||||
newValue = EditorGUILayout.Vector4Field(content, oldValue);
|
||||
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
valueProperty.vector4Value = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b864e9955ea52c1439bd7a5e691c3e75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,194 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Drawer helper for int substance inputs.
|
||||
/// </summary>
|
||||
internal static class SubstanceInputDrawerInt
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws int input.
|
||||
/// </summary>
|
||||
/// <param name="valueProperty"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <returns>True if value changed.</returns>
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
int value;
|
||||
bool changed;
|
||||
|
||||
if (content.Description.Label == "$randomseed")
|
||||
{
|
||||
changed = DrawRandomSeedButton(valueProperty, content, out value);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
case SubstanceWidgetType.ToggleButton:
|
||||
changed = DrawToggleButton(valueProperty, content as SubstanceIntGUIContent, out value);
|
||||
break;
|
||||
|
||||
case SubstanceWidgetType.Slider:
|
||||
changed = DrawSlider(valueProperty, content as SubstanceIntGUIContent, out value);
|
||||
break;
|
||||
|
||||
case SubstanceWidgetType.ComboBox:
|
||||
changed = DrawComboBox(valueProperty, content as SubstanceIntGUIContent, out value);
|
||||
break;
|
||||
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content, out value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputInt(inputID, value);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the int input as a toggle button.
|
||||
/// </summary>
|
||||
/// <param name="valueProperty">Value property.</param>
|
||||
/// <param name="content">GUI content.</param>
|
||||
/// <returns>True if value changed.</returns>
|
||||
private static bool DrawToggleButton(SerializedProperty valueProperty, SubstanceIntGUIContent content, out int newValue)
|
||||
{
|
||||
newValue = 0;
|
||||
var oldValue = valueProperty.intValue != 0;
|
||||
var newValueToggle = EditorGUILayout.Toggle(content, oldValue);
|
||||
|
||||
if (oldValue != newValueToggle)
|
||||
{
|
||||
newValue = newValueToggle ? 1 : 0;
|
||||
valueProperty.intValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the int input as a slider.
|
||||
/// </summary>
|
||||
/// <param name="valueProperty">Value property.</param>
|
||||
/// <param name="content">GUI content.</param>
|
||||
/// <returns>True if value changed.</returns>
|
||||
private static bool DrawSlider(SerializedProperty valueProperty, SubstanceIntGUIContent content, out int newValue)
|
||||
{
|
||||
var numDescription = content.NumericalDescription;
|
||||
|
||||
var maxValue = numDescription.MaxValue;
|
||||
var minValue = numDescription.MinValue;
|
||||
|
||||
var oldValue = valueProperty.intValue;
|
||||
newValue = EditorGUILayout.IntSlider(content, oldValue, minValue, maxValue);
|
||||
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
valueProperty.intValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the int input as combo box.
|
||||
/// </summary>
|
||||
/// <param name="valueProperty">Value property.</param>
|
||||
/// <param name="content">GUI content.</param>
|
||||
/// <returns>True if value changed.</returns>
|
||||
private static bool DrawComboBox(SerializedProperty valueProperty, SubstanceIntGUIContent content, out int newValue)
|
||||
{
|
||||
var specializedContent = content as SubstanceIntComboBoxGUIContent;
|
||||
|
||||
var oldValue = valueProperty.intValue;
|
||||
newValue = EditorGUILayout.IntPopup(content, oldValue, specializedContent.EnumValuesGUI, specializedContent.EnumValues);
|
||||
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
valueProperty.intValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default input render.
|
||||
/// </summary>
|
||||
/// <param name="valueProperty">Value property.</param>
|
||||
/// <param name="content">GUI content.</param>
|
||||
/// <returns>True if value changed.</returns>
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out int newValue)
|
||||
{
|
||||
var oldValue = valueProperty.intValue;
|
||||
newValue = EditorGUILayout.IntField(content, oldValue);
|
||||
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
valueProperty.intValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the random seed button.
|
||||
/// </summary>
|
||||
/// <param name="valueProperty">Value property.</param>
|
||||
/// <param name="content">GUI content.</param>
|
||||
/// <returns>True if value changed.</returns>
|
||||
private static bool DrawRandomSeedButton(SerializedProperty valueProperty, SubstanceInputGUIContent content, out int newValue)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
newValue = valueProperty.intValue;
|
||||
int minimum = 0;
|
||||
int maximum = 10000;
|
||||
|
||||
int labelWidth = (int)EditorGUIUtility.labelWidth - 15;
|
||||
int fieldWidth = 50;
|
||||
|
||||
content.text = "Random Seed";
|
||||
content.tooltip = "$randomseed: the overall random aspect of the texture";
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
int buttonWidth = (int)EditorGUIUtility.currentViewWidth - labelWidth - fieldWidth - 60;
|
||||
|
||||
EditorGUILayout.LabelField(content, GUILayout.Width(labelWidth), GUILayout.ExpandWidth(true));
|
||||
|
||||
if (GUILayout.Button("Randomize", GUILayout.Width(buttonWidth)))
|
||||
{
|
||||
newValue = UnityEngine.Random.Range(minimum, maximum);
|
||||
valueProperty.intValue = newValue;
|
||||
result = true;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
newValue = EditorGUILayout.IntField(newValue, GUILayout.Width(fieldWidth));
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
newValue = (newValue < minimum) ? minimum : (newValue > maximum) ? maximum : newValue;
|
||||
valueProperty.intValue = newValue;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91b2fc4c484fa3f48804e6352c3d51d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,95 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerInt2
|
||||
{
|
||||
private static readonly string[] _resulutions = { "256", "512", "1024", "2048", "4096" };
|
||||
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
Vector2Int newValue;
|
||||
bool changed;
|
||||
|
||||
if (IsSizeAttribute(content))
|
||||
{
|
||||
changed = DrawResolutionSelection(valueProperty, content, out newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = DrawDefault(valueProperty, content, out newValue);
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputInt2(inputID, newValue);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool DrawResolutionSelection(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector2Int newValue)
|
||||
{
|
||||
Vector2Int oldValue = valueProperty.vector2IntValue;
|
||||
var currentIndex = GetEnumIndex(oldValue);
|
||||
int newIndex = EditorGUILayout.Popup("Output Resolution", currentIndex, _resulutions);
|
||||
|
||||
if (currentIndex != newIndex)
|
||||
{
|
||||
newValue = GetValueFromIndex(newIndex);
|
||||
valueProperty.vector2IntValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
newValue = new Vector2Int();
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector2Int newValue)
|
||||
{
|
||||
Vector2Int oldValue = valueProperty.vector2IntValue;
|
||||
newValue = EditorGUILayout.Vector2IntField(content, oldValue);
|
||||
|
||||
if (newValue != oldValue)
|
||||
{
|
||||
valueProperty.vector2IntValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsSizeAttribute(GUIContent content)
|
||||
{
|
||||
return content.text == "$outputsize";
|
||||
}
|
||||
|
||||
private static int GetEnumIndex(Vector2Int data)
|
||||
{
|
||||
switch (data.x)
|
||||
{
|
||||
case 8: return 0;
|
||||
case 9: return 1;
|
||||
case 10: return 2;
|
||||
case 11: return 3;
|
||||
case 12: return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector2Int GetValueFromIndex(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return new Vector2Int(8, 8);
|
||||
case 1: return new Vector2Int(9, 9);
|
||||
case 2: return new Vector2Int(10, 10);
|
||||
case 3: return new Vector2Int(11, 11);
|
||||
case 4: return new Vector2Int(12, 12);
|
||||
default:
|
||||
return new Vector2Int(8, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17a55141ccae8494f8ea0e29affd3a9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,41 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerInt3
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
Vector3Int newValue;
|
||||
bool changed;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content, out newValue);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputInt3(inputID, newValue);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Vector3Int newValue)
|
||||
{
|
||||
var previewValue = valueProperty.vector3IntValue;
|
||||
newValue = EditorGUILayout.Vector3IntField(content, previewValue);
|
||||
|
||||
if (newValue != previewValue)
|
||||
{
|
||||
valueProperty.vector3IntValue = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c99f44dae8ff5f4097e558c6f881451
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,211 @@
|
||||
using UnityEditor;
|
||||
using Adobe.Substance;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerInt4
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
int value0;
|
||||
int value1;
|
||||
int value2;
|
||||
int value3;
|
||||
bool changed;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
case SubstanceWidgetType.Slider:
|
||||
changed = DrawSliderWidget(valueProperty, content as SubstanceInt4GUIContent, out value0, out value1, out value2, out value3);
|
||||
break;
|
||||
|
||||
case SubstanceWidgetType.Color:
|
||||
changed = DrawColorWidget(valueProperty, content as SubstanceInt4GUIContent, out value0, out value1, out value2, out value3);
|
||||
break;
|
||||
//TODO: Add edge cases here.
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content as SubstanceInt4GUIContent, out value0, out value1, out value2, out value3);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
handler.SetInputInt4(inputID, value0, value1, value2, value3);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInt4GUIContent content, out int newValue0, out int newValue1, out int newValue2, out int newValue3)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
var value0 = valueProperty?.FindPropertyRelative("Data0");
|
||||
var value1 = valueProperty?.FindPropertyRelative("Data1");
|
||||
var value2 = valueProperty?.FindPropertyRelative("Data2");
|
||||
var value3 = valueProperty?.FindPropertyRelative("Data3");
|
||||
|
||||
var previewValue0 = value0.intValue;
|
||||
var previewValue1 = value1.intValue;
|
||||
var previewValue2 = value2.intValue;
|
||||
var previewValue3 = value3.intValue;
|
||||
|
||||
newValue0 = EditorGUILayout.IntField(content, previewValue0);
|
||||
newValue1 = EditorGUILayout.IntField(content, previewValue1);
|
||||
newValue2 = EditorGUILayout.IntField(content, previewValue2);
|
||||
newValue3 = EditorGUILayout.IntField(content, previewValue3);
|
||||
|
||||
if (newValue0 != previewValue0)
|
||||
{
|
||||
value0.intValue = newValue0;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue1 != previewValue1)
|
||||
{
|
||||
value1.intValue = newValue1;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue2 != previewValue2)
|
||||
{
|
||||
value2.intValue = newValue2;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue3 != previewValue3)
|
||||
{
|
||||
value3.intValue = newValue3;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool DrawSliderWidget(SerializedProperty valueProperty, SubstanceInt4GUIContent content, out int newValue0, out int newValue1, out int newValue2, out int newValue3)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
int rightValue0 = 100;
|
||||
int rightValue1 = 100;
|
||||
int rightValue2 = 100;
|
||||
int rightValue3 = 100;
|
||||
|
||||
int leftValue0 = 0;
|
||||
int leftValue1 = 0;
|
||||
int leftValue2 = 0;
|
||||
int leftValue3 = 0;
|
||||
|
||||
var int4NumbericalDescription = content.NumericalDescription;
|
||||
|
||||
if (int4NumbericalDescription != null)
|
||||
{
|
||||
leftValue0 = int4NumbericalDescription.MinValue0;
|
||||
leftValue1 = int4NumbericalDescription.MinValue1;
|
||||
leftValue2 = int4NumbericalDescription.MinValue2;
|
||||
leftValue3 = int4NumbericalDescription.MinValue3;
|
||||
|
||||
rightValue0 = int4NumbericalDescription.MaxValue0;
|
||||
rightValue1 = int4NumbericalDescription.MaxValue1;
|
||||
rightValue2 = int4NumbericalDescription.MaxValue2;
|
||||
rightValue3 = int4NumbericalDescription.MaxValue3;
|
||||
}
|
||||
|
||||
var value0 = valueProperty?.FindPropertyRelative("Data0");
|
||||
var value1 = valueProperty?.FindPropertyRelative("Data1");
|
||||
var value2 = valueProperty?.FindPropertyRelative("Data2");
|
||||
var value3 = valueProperty?.FindPropertyRelative("Data3");
|
||||
|
||||
var previewValue0 = value0.intValue;
|
||||
var previewValue1 = value1.intValue;
|
||||
var previewValue2 = value2.intValue;
|
||||
var previewValue3 = value3.intValue;
|
||||
|
||||
newValue0 = EditorGUILayout.IntSlider(content, previewValue0, leftValue0, rightValue0);
|
||||
newValue1 = EditorGUILayout.IntSlider(content, previewValue1, leftValue1, rightValue1);
|
||||
newValue2 = EditorGUILayout.IntSlider(content, previewValue2, leftValue2, rightValue2);
|
||||
newValue3 = EditorGUILayout.IntSlider(content, previewValue3, leftValue3, rightValue3);
|
||||
|
||||
if (newValue0 != previewValue0)
|
||||
{
|
||||
value0.intValue = newValue0;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue1 != previewValue1)
|
||||
{
|
||||
value1.intValue = newValue1;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue2 != previewValue2)
|
||||
{
|
||||
value2.intValue = newValue2;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue3 != previewValue3)
|
||||
{
|
||||
value3.intValue = newValue3;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool DrawColorWidget(SerializedProperty valueProperty, SubstanceInt4GUIContent content, out int newValue0, out int newValue1, out int newValue2, out int newValue3)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
var value0 = valueProperty?.FindPropertyRelative("Data0");
|
||||
var value1 = valueProperty?.FindPropertyRelative("Data1");
|
||||
var value2 = valueProperty?.FindPropertyRelative("Data2");
|
||||
var value3 = valueProperty?.FindPropertyRelative("Data3");
|
||||
|
||||
var previewValue0 = value0.intValue;
|
||||
var previewValue1 = value1.intValue;
|
||||
var previewValue2 = value2.intValue;
|
||||
var previewValue3 = value3.intValue;
|
||||
|
||||
var floatValue0 = ((float)previewValue0) / 255f;
|
||||
var floatValue1 = ((float)previewValue1) / 255f;
|
||||
var floatValue2 = ((float)previewValue2) / 255f;
|
||||
var floatValue3 = ((float)previewValue3) / 255f;
|
||||
|
||||
Color color = new Color(floatValue0, floatValue1, floatValue2, floatValue3);
|
||||
|
||||
var newColor = EditorGUILayout.ColorField(content, color);
|
||||
|
||||
newValue0 = (int)newColor.r * 255;
|
||||
newValue1 = (int)newColor.g * 255;
|
||||
newValue2 = (int)newColor.b * 255;
|
||||
newValue3 = (int)newColor.a * 255;
|
||||
|
||||
if (newValue0 != previewValue0)
|
||||
{
|
||||
value0.intValue = newValue0;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue1 != previewValue1)
|
||||
{
|
||||
value1.intValue = newValue1;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue2 != previewValue2)
|
||||
{
|
||||
value2.intValue = newValue2;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (newValue3 != previewValue3)
|
||||
{
|
||||
value3.intValue = newValue3;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6083c230932064544b0beca8c8228f62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,35 @@
|
||||
using UnityEditor;
|
||||
using Adobe.Substance;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerString
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
bool changed;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
var stringValue = valueProperty.stringValue;
|
||||
handler.SetInputString(inputID, stringValue);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(valueProperty, content);
|
||||
return EditorGUI.EndChangeCheck();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ac347008a541b247a481fafa2196b14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,61 @@
|
||||
using Adobe.Substance;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.SubstanceEditor
|
||||
{
|
||||
internal static class SubstanceInputDrawerTexture
|
||||
{
|
||||
public static bool DrawInput(SerializedProperty valueProperty, SubstanceInputGUIContent content, SubstanceNativeGraph handler, int inputID)
|
||||
{
|
||||
Texture2D newValue;
|
||||
bool changed;
|
||||
|
||||
switch (content.Description.WidgetType)
|
||||
{
|
||||
default:
|
||||
changed = DrawDefault(valueProperty, content, out newValue);
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (newValue != null)
|
||||
{
|
||||
var pixels = newValue.GetPixels32();
|
||||
handler.SetInputTexture2D(inputID, pixels, newValue.width, newValue.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.SetInputTexture2DNull(inputID);
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool DrawDefault(SerializedProperty valueProperty, SubstanceInputGUIContent content, out Texture2D newValue)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.ObjectField(valueProperty, content);
|
||||
var changed = EditorGUI.EndChangeCheck();
|
||||
newValue = null;
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (valueProperty.objectReferenceValue != null)
|
||||
{
|
||||
newValue = valueProperty.objectReferenceValue as Texture2D;
|
||||
|
||||
if (newValue != null)
|
||||
{
|
||||
if (!newValue.isReadable)
|
||||
TextureUtils.SetReadableFlag(newValue, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07aca6dfe5b18924ba359d2f53a2ac34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user