updated with enemy
This commit is contained in:
148
Assets/Adobe/Substance3DForUnity/Runtime/Scripts/Engine.cs
Normal file
148
Assets/Adobe/Substance3DForUnity/Runtime/Scripts/Engine.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
public class Engine
|
||||
{
|
||||
private enum LoadState : uint
|
||||
{
|
||||
Engine_Unloaded = 0x00u, //!< Engine is currently not loaded
|
||||
Engine_Loaded = 0x02u, //!< The engine is loaded
|
||||
Engine_FatalError = 0x04u, //!< An unrecoverable error has occurred
|
||||
}
|
||||
|
||||
private static LoadState sLoadState = LoadState.Engine_Unloaded;
|
||||
|
||||
public static bool IsInitialized => sLoadState == LoadState.Engine_Loaded;
|
||||
|
||||
#if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR
|
||||
private const int MAX_TEXTURE_SIZE = 512;
|
||||
private const int MEMORY_BUGET = 512;
|
||||
#else
|
||||
private const int MEMORY_BUGET = 2048;
|
||||
#endif
|
||||
|
||||
public static string Version()
|
||||
{
|
||||
var version_ptr = NativeMethods.sbsario_get_version();
|
||||
return Marshal.PtrToStringAnsi(version_ptr);
|
||||
}
|
||||
|
||||
public static string GetHash()
|
||||
{
|
||||
var version_ptr = NativeMethods.sbsario_get_hash();
|
||||
return Marshal.PtrToStringAnsi(version_ptr);
|
||||
}
|
||||
|
||||
//! @brief Initialize the Substance Engine
|
||||
//! @param modulePath Path to the native module, only used if native module
|
||||
//! dynamic loading is enabled in the managed library
|
||||
//! @param enginePath Path to the Substance engine on disk, only used if
|
||||
//! dynamic engine loading is enabled in the native library
|
||||
public static void Initialize(string pluginPath, string enginePath)
|
||||
{
|
||||
if (sLoadState == LoadState.Engine_Loaded)
|
||||
return;
|
||||
|
||||
IntPtr memoryBudget = (IntPtr)MEMORY_BUGET;
|
||||
|
||||
var code = (ErrorCode)NativeMethods.sbsario_initialize(pluginPath, enginePath, memoryBudget);
|
||||
|
||||
// On success, set the engine state to loaded
|
||||
if (code == ErrorCode.SBSARIO_ERROR_OK)
|
||||
sLoadState = LoadState.Engine_Loaded;
|
||||
|
||||
if (code != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(code);
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (sLoadState == LoadState.Engine_Loaded)
|
||||
return;
|
||||
|
||||
IntPtr memoryBudget = (IntPtr)MEMORY_BUGET;
|
||||
|
||||
var code = (ErrorCode)NativeMethods.sbsario_initialize(null, null, memoryBudget);
|
||||
|
||||
if (sLoadState == LoadState.Engine_Unloaded)
|
||||
{
|
||||
// On success, set the engine state to loaded
|
||||
if (code == ErrorCode.SBSARIO_ERROR_OK)
|
||||
sLoadState = LoadState.Engine_Loaded;
|
||||
}
|
||||
|
||||
if (code != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(code);
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
var code = (ErrorCode)NativeMethods.sbsario_shutdown();
|
||||
|
||||
if (sLoadState == LoadState.Engine_Loaded)
|
||||
{
|
||||
// On success, set the engine to an unloaded state
|
||||
if (code == ErrorCode.SBSARIO_ERROR_OK)
|
||||
sLoadState = LoadState.Engine_Unloaded;
|
||||
}
|
||||
|
||||
if (code != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(code);
|
||||
}
|
||||
|
||||
public static SubstanceNativeGraph OpenFile(byte[] data, int graphID)
|
||||
{
|
||||
if (sLoadState != LoadState.Engine_Loaded)
|
||||
throw new ArgumentException("Engine must be loaded before creating Native Handler");
|
||||
|
||||
var substanceFile = new SubstanceNativeGraph(data, graphID);
|
||||
return substanceFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the total graph count for this substance object.
|
||||
/// </summary>
|
||||
/// <returns>Total graph count.</returns>
|
||||
public static int GetFileGraphCount(byte[] fileContent)
|
||||
{
|
||||
int size = Marshal.SizeOf(fileContent[0]) * fileContent.Length;
|
||||
var nativeMemory = Marshal.AllocHGlobal(size);
|
||||
Marshal.Copy(fileContent, 0, nativeMemory, size);
|
||||
|
||||
try
|
||||
{
|
||||
var handler = NativeMethods.sbsario_sbsar_load_from_memory(nativeMemory, (IntPtr)size);
|
||||
|
||||
if (handler == default)
|
||||
throw new ArgumentException();
|
||||
|
||||
return (int)NativeMethods.sbsario_sbsar_get_graph_count(handler);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (nativeMemory != default)
|
||||
Marshal.FreeHGlobal(nativeMemory);
|
||||
}
|
||||
}
|
||||
|
||||
private static double InvPow(double pBase, double pResult)
|
||||
{
|
||||
double exposent = Math.Log(pResult) / Math.Log(pBase);
|
||||
return exposent;
|
||||
}
|
||||
|
||||
private static bool IsPowerOfTwo(double number)
|
||||
{
|
||||
double log = Math.Log(number, 2);
|
||||
double pow = Math.Pow(2, Math.Round(log));
|
||||
return pow == number;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e9d31db8a6b5b544b6a12387f39d7e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33b96c1a3b96fcb45b2fa65b50de541b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
public class SubstanceNotInitializedException : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public class SubstanceEngineNotFoundException : Exception
|
||||
{
|
||||
public SubstanceEngineNotFoundException(string engine) : base($"Substance engine not found {engine}")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class SubstanceException : Exception
|
||||
{
|
||||
internal SubstanceException(ErrorCode code) : base(code.GetMessage())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09b34d2c2d194da42bec016057a9ba68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 551ddb489d69d334986aac5d60ec4660
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Numeric type union
|
||||
//! @note The size will need to be changed if the API
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
internal struct DataInternalNumeric
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public int mIntData0;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public int mIntData1;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public int mIntData2;
|
||||
|
||||
[FieldOffset(12)]
|
||||
public int mIntData3;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public float mFloatData0;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public float mFloatData1;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public float mFloatData2;
|
||||
|
||||
[FieldOffset(12)]
|
||||
public float mFloatData3;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public IntPtr mPtr;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public NativeDataImage ImageData;
|
||||
}
|
||||
|
||||
//! @brief Separate type for outputs
|
||||
} // namespace Alg.Sbsario
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81de55a495f8b1c46be3fa485ad32aa0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f96894eae7ca5a4abd70a163c1e956e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,12 @@
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Enum type mapping from sbsario to C#
|
||||
internal enum ErrorCode : uint
|
||||
{
|
||||
SBSARIO_ERROR_OK = 0x00u, //!< No error has occurred
|
||||
SBSARIO_ERROR_STATE = 0x01u, //!< Call made with an invalid state
|
||||
SBSARIO_ERROR_INVALID = 0x02u, //!< An invalid argument was given to the api
|
||||
SBSARIO_ERROR_UNKNOWN = 0x03u, //!< An unspecified error has occurred
|
||||
SBSARIO_ERROR_FAILURE = 0x04u, //!< The operation failed to complete
|
||||
}
|
||||
} // namespace Alg.Sbsario
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b566521bda0b2c47a8cc502717e65b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
internal enum HVFlip
|
||||
{
|
||||
SBSARIO_HVFLIP_NO = 0x0, //!< No flipping (default value)
|
||||
SBSARIO_HVFLIP_HORIZONTAL = 0x1, //!< Horizontal flip
|
||||
SBSARIO_HVFLIP_VERTICAL = 0x2, //!< Vertical flip
|
||||
SBSARIO_HVFLIP_BOTH = 0x3 //!< Horizontal and Vertical flip
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9687bfad244a5d749b109a35754b97e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,64 @@
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Image format
|
||||
internal enum ImageFormat : int
|
||||
{
|
||||
// 2 bits reserved for the bytes per channel
|
||||
SBSARIO_IMAGE_FORMAT_8B = 0x00,
|
||||
|
||||
SBSARIO_IMAGE_FORMAT_16B = 0x01,
|
||||
SBSARIO_IMAGE_FORMAT_32B = 0x02,
|
||||
/* Unused - 0x03u */
|
||||
SBSARIO_IMAGE_FORMAT_BITDEPTH_MASK = 0x03,
|
||||
|
||||
// 2 bits reserved for the number of channels
|
||||
SBSARIO_IMAGE_FORMAT_RGBA = 0x00,
|
||||
|
||||
SBSARIO_IMAGE_FORMAT_RGBX = 0x04,
|
||||
SBSARIO_IMAGE_FORMAT_RGB = 0x08,
|
||||
SBSARIO_IMAGE_FORMAT_L = 0x0c,
|
||||
SBSARIO_IMAGE_FORMAT_CHANNELS_MASK = 0x0c,
|
||||
|
||||
// 1 bit to determine integer or floating point
|
||||
SBSARIO_IMAGE_FORMAT_INT = 0x00,
|
||||
|
||||
SBSARIO_IMAGE_FORMAT_FLOAT = 0x10,
|
||||
|
||||
/* Format (2 bits) */
|
||||
SBSARIO_IMAGE_FORMAT_PF_RAW = 0x0, /**< Non-compressed flag */
|
||||
SBSARIO_IMAGE_FORMAT_PF_BC = 0x1 << 6, /**< DXT compression flag */
|
||||
SBSARIO_IMAGE_FORMAT_PF_PVRTC = 0x3 << 6, /**< PVRTC compression flag */
|
||||
SBSARIO_IMAGE_FORMAT_PF_ETC = 0x3 << 6, /**< ETC compression flag */
|
||||
SBSARIO_IMAGE_FORMAT_PF_Misc = 0x2 << 6, /**< Other compression flag */
|
||||
SBSARIO_IMAGE_FORMAT_PF_MASK_RAWFormat = 0x3 << 6,
|
||||
|
||||
// Combine integer and float bitfields to create more complex image types
|
||||
SBSARIO_IMAGE_FORMAT_8I = SBSARIO_IMAGE_FORMAT_8B | SBSARIO_IMAGE_FORMAT_INT,
|
||||
|
||||
SBSARIO_IMAGE_FORMAT_16I = SBSARIO_IMAGE_FORMAT_16B | SBSARIO_IMAGE_FORMAT_INT,
|
||||
SBSARIO_IMAGE_FORMAT_16F = SBSARIO_IMAGE_FORMAT_16B | SBSARIO_IMAGE_FORMAT_FLOAT,
|
||||
SBSARIO_IMAGE_FORMAT_32F = SBSARIO_IMAGE_FORMAT_32B | SBSARIO_IMAGE_FORMAT_FLOAT,
|
||||
SBSARIO_IMAGE_FORMAT_PRECISION_MASK = SBSARIO_IMAGE_FORMAT_BITDEPTH_MASK | 0x10
|
||||
}
|
||||
|
||||
//! @brief Enum representing the order of the output channels
|
||||
internal enum ChannelOrder : uint
|
||||
{
|
||||
SBSARIO_CHANNEL_ORDER_INVALID = 0x00u,
|
||||
|
||||
SBSARIO_CHANNEL_ORDER_RGBA = 0xe4u,
|
||||
SBSARIO_CHANNEL_ORDER_BGRA = 0xc6u,
|
||||
SBSARIO_CHANNEL_ORDER_ABGR = 0x1bu,
|
||||
SBSARIO_CHANNEL_ORDER_ARGB = 0x39u,
|
||||
|
||||
SBSARIO_CHANNEL_RED_MASK = 0x03u,
|
||||
SBSARIO_CHANNEL_GREEN_MASK = 0x0cu,
|
||||
SBSARIO_CHANNEL_BLUE_MASK = 0x30u,
|
||||
SBSARIO_CHANNEL_ALPHA_MASK = 0xc0u,
|
||||
|
||||
SBSARIO_CHANNEL_RED_RSHIFT = 0x00u,
|
||||
SBSARIO_CHANNEL_GREEN_RSHIFT = 0x02u,
|
||||
SBSARIO_CHANNEL_BLUE_RSHIFT = 0x04u,
|
||||
SBSARIO_CHANNEL_ALPHA_RSHIFT = 0x06u,
|
||||
}
|
||||
} // namespace Alg.Sbsario
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72a712966a00a97428f8275064ad75fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,38 @@
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Enum describing whether the data is an input or output
|
||||
internal enum DataType : uint
|
||||
{
|
||||
SBSARIO_DATA_INVALID = 0x00u, //!< Invalid data
|
||||
SBSARIO_DATA_INPUT = 0x01u, //!< Input data
|
||||
SBSARIO_DATA_OUTPUT = 0x02u, //!< Output data
|
||||
}
|
||||
|
||||
//! @brief Enum describing the value type of an input or output
|
||||
internal enum ValueType : uint
|
||||
{
|
||||
SBSARIO_VALUE_FLOAT = 0x00u, //!< Float type
|
||||
SBSARIO_VALUE_FLOAT2 = 0x01u, //!< Float vector with two elements
|
||||
SBSARIO_VALUE_FLOAT3 = 0x02u, //!< Float vector with three elements
|
||||
SBSARIO_VALUE_FLOAT4 = 0x03u, //!< Float vector with four elements
|
||||
SBSARIO_VALUE_INT = 0x04u, //!< Integer type
|
||||
SBSARIO_VALUE_INT2 = 0x05u, //!< Integer vector with two elements
|
||||
SBSARIO_VALUE_INT3 = 0x06u, //!< Integer vector with three elements
|
||||
SBSARIO_VALUE_INT4 = 0x07u, //!< Integer vector with four elements
|
||||
SBSARIO_VALUE_IMAGE = 0x08u, //!< Image type
|
||||
SBSARIO_VALUE_STRING = 0x09u, //!< String type, input only
|
||||
SBSARIO_VALUE_FONT = 0x0Au, //!< Font type, input only
|
||||
}
|
||||
|
||||
internal enum WidgetType : uint
|
||||
{
|
||||
SBSARIO_WIDGET_NOWIDGET = 0x00u,
|
||||
SBSARIO_WIDGET_SLIDER = 0x01u,
|
||||
SBSARIO_WIDGET_ANGLE = 0x02u,
|
||||
SBSARIO_WIDGET_COLOR = 0x03u,
|
||||
SBSARIO_WIDGET_TOGGLEBUTTON = 0x04u,
|
||||
SBSARIO_WIDGET_COMBOBOX = 0x05u,
|
||||
SBSARIO_WIDGET_IMAGE = 0x06u,
|
||||
SBSARIO_WIDGET_POSITION = 0x07u,
|
||||
}
|
||||
} // namespace Alg.Sbsario
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ba3c765d94cc4a479c0a6df314289c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeDataImage
|
||||
{
|
||||
/** @brief Pointer to the underlying image data */
|
||||
public IntPtr data;
|
||||
|
||||
/** @brief The width in pixels of the larget mipmap */
|
||||
public IntPtr width;
|
||||
|
||||
/** @brief The height in pixels of the largest mipmap */
|
||||
public IntPtr height;
|
||||
|
||||
/** @brief The number of mipmaps in the chain. The largest map (level 0)
|
||||
will be the first in memory, with width/height as its dimensions
|
||||
*/
|
||||
public IntPtr mipmaps;
|
||||
|
||||
/** @brief Channel order enum, describing the channel index order */
|
||||
public ChannelOrder channel_order;
|
||||
|
||||
/** @brief Image format enum, describing the bitdepth and channel size
|
||||
of the image in memory
|
||||
*/
|
||||
public ImageFormat image_format;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"width:{width} \n " +
|
||||
$"height:{height}\n" +
|
||||
$"mipmaps:{mipmaps}\n" +
|
||||
$"image_format:{(int)image_format} \n" +
|
||||
$"channel_order:{(int)channel_order}";
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeData
|
||||
{
|
||||
/** @brief Type descriptor of the data value */
|
||||
public ValueType ValueType;
|
||||
|
||||
/** @brief Descriptor of whether the data is for inputs or outputs */
|
||||
public DataType DataType;
|
||||
|
||||
/** @brief Data index that this is associated with, either of the input
|
||||
if it is input data, or of the output if it is output/result
|
||||
data. */
|
||||
public IntPtr Index;
|
||||
|
||||
/** @brief Internal data, of which the valid type is determined by
|
||||
the value_type member.*/
|
||||
public DataInternalNumeric Data;
|
||||
}
|
||||
} // namespace Adobe.Substance
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df487c43ab54e7e4eaaf4c48d091656b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeInputVisibility
|
||||
{
|
||||
public IntPtr Index;
|
||||
|
||||
public IntPtr IsVisible;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 074a7ebe4a960264d9ade0ce2e8404b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,86 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
internal static class NativeConsts
|
||||
{
|
||||
public const uint UseDefault = ~0u;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
internal struct NativeOutputFormatComponent
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public uint outputIndex;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public ShuffleIndex ShuffleIndex;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public float levelMin;
|
||||
|
||||
[FieldOffset(12)]
|
||||
public float levelMax;
|
||||
|
||||
public static NativeOutputFormatComponent CreateDefault()
|
||||
{
|
||||
return new NativeOutputFormatComponent
|
||||
{
|
||||
outputIndex = NativeConsts.UseDefault,
|
||||
levelMin = NativeConsts.UseDefault,
|
||||
levelMax = NativeConsts.UseDefault
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 84)]
|
||||
internal struct NativeOutputFormat
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public uint format;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public uint mipmapLevelsCount;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public HVFlip hvFlip;
|
||||
|
||||
[FieldOffset(12)]
|
||||
public uint forceWidth;
|
||||
|
||||
[FieldOffset(16)]
|
||||
public uint forceHeight;
|
||||
|
||||
[FieldOffset(20)]
|
||||
public NativeOutputFormatComponent ChannelComponent0;
|
||||
|
||||
[FieldOffset(36)]
|
||||
public NativeOutputFormatComponent ChannelComponent1;
|
||||
|
||||
[FieldOffset(52)]
|
||||
public NativeOutputFormatComponent ChannelComponent2;
|
||||
|
||||
[FieldOffset(68)]
|
||||
public NativeOutputFormatComponent ChannelComponent3;
|
||||
|
||||
public static NativeOutputFormat CreateDefault()
|
||||
{
|
||||
return new NativeOutputFormat
|
||||
{
|
||||
format = NativeConsts.UseDefault,
|
||||
mipmapLevelsCount = NativeConsts.UseDefault,
|
||||
hvFlip = HVFlip.SBSARIO_HVFLIP_NO,
|
||||
forceWidth = NativeConsts.UseDefault,
|
||||
forceHeight = NativeConsts.UseDefault,
|
||||
|
||||
ChannelComponent0 = NativeOutputFormatComponent.CreateDefault(),
|
||||
ChannelComponent1 = NativeOutputFormatComponent.CreateDefault(),
|
||||
ChannelComponent2 = NativeOutputFormatComponent.CreateDefault(),
|
||||
ChannelComponent3 = NativeOutputFormatComponent.CreateDefault()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80e96a42636b99049accabcee0d069dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativePhysicalSize
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
}
|
||||
} // namespace Adobe.Substance
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4897bada61d9a4ba3b55b9f20fe445cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
/// <summary>
|
||||
/// Struct for handlign sending and receiving preset XML from native to managed code.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativePreset
|
||||
{
|
||||
public IntPtr XMLString;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16bd92bd193ee9044b52b3607ef613c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeThumbnail
|
||||
{
|
||||
public IntPtr Size;
|
||||
public IntPtr Data;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 219b8713c6f86934ba2bb9d9d3cb18f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Numeric type union
|
||||
//! @note The size will need to be changed if the API
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
internal struct NumericDescriptValue
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public int mIntData0;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public int mIntData1;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public int mIntData2;
|
||||
|
||||
[FieldOffset(12)]
|
||||
public int mIntData3;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public float mFloatData0;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public float mFloatData1;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public float mFloatData2;
|
||||
|
||||
[FieldOffset(12)]
|
||||
public float mFloatData3;
|
||||
}
|
||||
|
||||
//! @brief Managed representation of the native sbsario input desc type
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeNumericInputDesc
|
||||
{
|
||||
public IntPtr index;
|
||||
|
||||
/** @brief Unique string identifier for x axis of a vector input. ('X' if nullptr) */
|
||||
public IntPtr xLabel;
|
||||
|
||||
/** @brief Unique string identifier for y axis of a vector input. ('Y' if nullptr) */
|
||||
public IntPtr yLabel;
|
||||
|
||||
/** @brief Unique string identifier for z axis of a vector input. ('Z' if nullptr) */
|
||||
public IntPtr zLabel;
|
||||
|
||||
/** @brief Unique string identifier for w axis of a vector input. ('W' if nullptr) */
|
||||
public IntPtr wLabel;
|
||||
|
||||
/** @brief Unique string identifier for the false state of a bool int. */
|
||||
public IntPtr LabelFalse;
|
||||
|
||||
/** @brief Unique string identifier for the true state of a bool int. */
|
||||
public IntPtr LabelTrue;
|
||||
|
||||
/** @brief Step to be used for a slider input. */
|
||||
public float sliderStep;
|
||||
|
||||
/** @brief Bool value that determs if the slider must clamp. */
|
||||
public IntPtr sliderClamp;
|
||||
|
||||
/** @brief Internal data, of which the valid type is determined by
|
||||
the value_type member.
|
||||
*/
|
||||
public NumericDescriptValue default_value;
|
||||
|
||||
public NumericDescriptValue min_value;
|
||||
|
||||
public NumericDescriptValue max_value;
|
||||
|
||||
public IntPtr enumValueCount;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeEnumInputDesc
|
||||
{
|
||||
public IntPtr label;
|
||||
|
||||
public NumericDescriptValue value;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab2bb5d412dd1684ab655586f81aa0e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Managed representation of the native sbsario graph descriptor structure
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeGraphDesc
|
||||
{
|
||||
//! @brief Unique string label of the graph
|
||||
public IntPtr mLabel;
|
||||
|
||||
//! @brief Description set for the graph
|
||||
public IntPtr mDescription;
|
||||
|
||||
//! @brief Category of the graph
|
||||
public IntPtr mCategory;
|
||||
|
||||
//! @brief Semicolon separated list of keywords
|
||||
public IntPtr mKeywords;
|
||||
|
||||
//! @brief Graph author
|
||||
public IntPtr mAuthor;
|
||||
|
||||
//! @brief Graph author website url
|
||||
public IntPtr mAuthorUrl;
|
||||
|
||||
//! @brief Graph user data
|
||||
public IntPtr mUserTag;
|
||||
}
|
||||
} // namespace Adobe.Substance
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34e809fb674bca84f86309e85e7595fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Managed representation of the native sbsario input desc type
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeInputDesc
|
||||
{
|
||||
//! @brief Unique string identifier of the input
|
||||
public IntPtr mIdentifier;
|
||||
|
||||
//! @brief Display label of the input
|
||||
public IntPtr mLabel;
|
||||
|
||||
//! @brief Gui group of the input.
|
||||
public IntPtr GuiGroup;
|
||||
|
||||
//! @brief Description of the input.
|
||||
public IntPtr GuiDescription;
|
||||
|
||||
//! @brief GUI visibility condition.
|
||||
public IntPtr GuiVisibleIf;
|
||||
|
||||
//! @brief Index of the input
|
||||
public IntPtr mIndex;
|
||||
|
||||
//! @brief Type of widget used for the input
|
||||
public IntPtr inputWidgetType;
|
||||
|
||||
//! @brief Type of the input
|
||||
public IntPtr mValueType;
|
||||
}
|
||||
} // namespace Alg.Sbsario
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66f8f0c2765100b4ea04428bb0b07a05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
//! @brief Managed representation of the native sbsario output desc type
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NativeOutputDesc
|
||||
{
|
||||
//! @brief Unique string identifier of the output
|
||||
public IntPtr mIdentifier;
|
||||
|
||||
//! @brief Display label for the output
|
||||
public IntPtr mLabel;
|
||||
|
||||
//! @brief Index of the output
|
||||
public UIntPtr mIndex;
|
||||
|
||||
//! @brief Image output format.
|
||||
public IntPtr mFormat;
|
||||
|
||||
//! @brief Type of the output
|
||||
public ValueType mValueType;
|
||||
|
||||
//! @brief Default usage for the output
|
||||
public IntPtr mChannelUsage;
|
||||
}
|
||||
} // namespace Alg.Sbsario
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b408381e48fca754193e7e75bc35e594
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1035
Assets/Adobe/Substance3DForUnity/Runtime/Scripts/NativeMethods.cs
Normal file
1035
Assets/Adobe/Substance3DForUnity/Runtime/Scripts/NativeMethods.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2acf0fc87821724f9a375683712fe70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 197303fc3cc196f4a804d1294dd46eaa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,31 @@
|
||||
#define SUBSTANCE_PROFILE_ENABLE
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
#if SUBSTANCE_PROFILE_ENABLE
|
||||
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
internal static class ProfileUtils
|
||||
{
|
||||
internal static void BeginSample(string name)
|
||||
{
|
||||
#if SUBSTANCE_PROFILE_ENABLE
|
||||
Profiler.BeginSample(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void EndSample()
|
||||
{
|
||||
#if SUBSTANCE_PROFILE_ENABLE
|
||||
Profiler.EndSample();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 504aaf43fe623354fa2b2c39cefa44ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e147d824023c2174fae33c079eb80d02
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,127 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
public class PluginPipelines
|
||||
{
|
||||
private static Pipeline current = Pipeline.UNKNOWN;
|
||||
private static string currentText = "UNKNOWN";
|
||||
|
||||
public static Pipeline GetCurrent()
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
public static string GetCurrentText()
|
||||
{
|
||||
return currentText;
|
||||
}
|
||||
|
||||
public static void SetCurrent(Pipeline pSetting)
|
||||
{
|
||||
switch (pSetting)
|
||||
{
|
||||
case Pipeline.HDRP:
|
||||
current = Pipeline.HDRP;
|
||||
currentText = "HDRP";
|
||||
break;
|
||||
|
||||
case Pipeline.URP:
|
||||
current = Pipeline.URP;
|
||||
currentText = "URP";
|
||||
break;
|
||||
|
||||
default:
|
||||
current = Pipeline.DEFAULT;
|
||||
currentText = "DEFAULT";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsUNKNOWN()
|
||||
{
|
||||
return (current == Pipeline.UNKNOWN);
|
||||
}
|
||||
|
||||
public static bool IsDEFAULT()
|
||||
{
|
||||
return (current == Pipeline.DEFAULT);
|
||||
}
|
||||
|
||||
public static bool IsHDRP()
|
||||
{
|
||||
return (current == Pipeline.HDRP);
|
||||
}
|
||||
|
||||
public static bool IsURP()
|
||||
{
|
||||
return (current == Pipeline.URP);
|
||||
}
|
||||
|
||||
public static void GetCurrentPipelineInUse()
|
||||
{
|
||||
if (IsUNKNOWN())
|
||||
{
|
||||
if (UnityPipeline.IsHDRP())
|
||||
SetCurrent(Pipeline.HDRP);
|
||||
else if (UnityPipeline.IsURP())
|
||||
SetCurrent(Pipeline.URP);
|
||||
else
|
||||
SetCurrent(Pipeline.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnityPipeline
|
||||
{
|
||||
public static bool IsHDRP()
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
bool bActive = false;
|
||||
|
||||
UnityEngine.Rendering.RenderPipelineAsset asset;
|
||||
asset = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset;
|
||||
|
||||
if ((asset != null) &&
|
||||
(asset.GetType().ToString().EndsWith(".HDRenderPipelineAsset")))
|
||||
{
|
||||
bActive = true;
|
||||
}
|
||||
|
||||
return bActive;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsURP()
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
bool bActive = false;
|
||||
|
||||
UnityEngine.Rendering.RenderPipelineAsset asset;
|
||||
asset = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset;
|
||||
|
||||
if ((asset != null) &&
|
||||
(asset.GetType().ToString().EndsWith("UniversalRenderPipelineAsset")))
|
||||
{
|
||||
bActive = true;
|
||||
}
|
||||
|
||||
return bActive;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public enum Pipeline
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
DEFAULT = 0,
|
||||
HDRP = 1,
|
||||
URP = 2
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba4c5727559f0ba4d99dbf399320b335
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,914 @@
|
||||
//! @file substancearchive.cs
|
||||
//! @brief Substance archive interface
|
||||
//! @author Galen Helfter - Adobe
|
||||
//! @date 20210609
|
||||
//! @copyright Adobe. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
using Adobe.Substance.Input;
|
||||
using Adobe.Substance.Input.Description;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
/// <summary>
|
||||
/// Object that represents a native C++ substance graph.
|
||||
/// </summary>
|
||||
public sealed class SubstanceNativeGraph : IDisposable
|
||||
{
|
||||
private IntPtr _handler;
|
||||
private bool _disposedValue;
|
||||
private bool _inRenderWork;
|
||||
|
||||
public bool IsInitialized { get; set; }
|
||||
|
||||
public bool InRenderWork
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return _inRenderWork;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_inRenderWork = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly int _fileGraphID;
|
||||
|
||||
/// <summary>
|
||||
/// Create a object that acts as a brige between Unity and Substance C++ SDK.
|
||||
/// </summary>
|
||||
/// <param name="fileContent">Content of the sbsar file.</param>
|
||||
/// <param name="targetGraphID">Target graph ID inside the file.</param>
|
||||
internal SubstanceNativeGraph(byte[] fileContent, int targetGraphID)
|
||||
{
|
||||
_fileGraphID = targetGraphID;
|
||||
int size = Marshal.SizeOf(fileContent[0]) * fileContent.Length;
|
||||
var nativeMemory = Marshal.AllocHGlobal(size);
|
||||
Marshal.Copy(fileContent, 0, nativeMemory, size);
|
||||
|
||||
try
|
||||
{
|
||||
_handler = NativeMethods.sbsario_sbsar_load_from_memory(nativeMemory, (IntPtr)size);
|
||||
|
||||
if (_handler == default)
|
||||
throw new ArgumentException();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (nativeMemory != default)
|
||||
Marshal.FreeHGlobal(nativeMemory);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders graph.
|
||||
/// </summary>
|
||||
/// <returns>Native render result.</returns>
|
||||
public IntPtr Render()
|
||||
{
|
||||
ErrorCode errorCode = (ErrorCode)NativeMethods.sbsario_sbsar_render(_handler, (IntPtr)_fileGraphID, out IntPtr result);
|
||||
|
||||
if (errorCode != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(errorCode);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get raw thumbnail data from graph.
|
||||
/// </summary>
|
||||
/// <returns>Raw graph thumbnail RGBA data.</returns>
|
||||
public byte[] GetThumbnail()
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_graph_thumbnail(_handler, (IntPtr)_fileGraphID, out NativeThumbnail thumbnail);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
if (thumbnail.Size == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
var thumbnailData = new byte[(int)thumbnail.Size];
|
||||
Marshal.Copy(thumbnail.Data, thumbnailData, 0, thumbnailData.Length);
|
||||
return thumbnailData;
|
||||
}
|
||||
|
||||
#region Presets
|
||||
|
||||
public string CreatePresetFromCurrentState()
|
||||
{
|
||||
//Alocate 1Mb for the preset file text.
|
||||
NativePreset preset = new NativePreset
|
||||
{
|
||||
XMLString = Marshal.AllocHGlobal(1024 * 1024)
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_make_preset_from_current_state(_handler, (IntPtr)_fileGraphID, ref preset);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
var stringResult = Marshal.PtrToStringAnsi(preset.XMLString);
|
||||
return stringResult;
|
||||
}
|
||||
finally
|
||||
{
|
||||
//Free native allocated memory.
|
||||
Marshal.FreeHGlobal(preset.XMLString);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply preset string to graph.
|
||||
/// </summary>
|
||||
/// <param name="presetXML"></param>
|
||||
public void ApplyPreset(string presetXML)
|
||||
{
|
||||
NativePreset preset = new NativePreset();
|
||||
preset.XMLString = Marshal.StringToHGlobalAnsi(presetXML);
|
||||
|
||||
try
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_apply_preset(_handler, (IntPtr)_fileGraphID, ref preset);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Always free the unmanaged string.
|
||||
Marshal.FreeHGlobal(preset.XMLString);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Presets
|
||||
|
||||
#region Output
|
||||
|
||||
/// <summary>
|
||||
/// Get the total output count for a given graph in the substance object.
|
||||
/// </summary>
|
||||
/// <returns>Total graph output count.</returns>
|
||||
public int GetOutputCount()
|
||||
{
|
||||
return (int)NativeMethods.sbsario_sbsar_get_output_count(_handler, (IntPtr)_fileGraphID);
|
||||
}
|
||||
|
||||
public SubstanceOutputDescription GetOutputDescription(int outputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_output_desc(_handler, (IntPtr)_fileGraphID, (IntPtr)outputID, out NativeOutputDesc inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
var identifier = Marshal.PtrToStringAnsi(inputDesc.mIdentifier);
|
||||
var label = Marshal.PtrToStringAnsi(inputDesc.mIdentifier);
|
||||
var channel = Marshal.PtrToStringAnsi(inputDesc.mChannelUsage);
|
||||
|
||||
if (string.IsNullOrEmpty(channel))
|
||||
{
|
||||
Debug.LogWarning($"Output {outputID} does not have a channel type. This output will not be rendered. ");
|
||||
channel = "unkown";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(identifier))
|
||||
{
|
||||
Debug.LogWarning($"Output {outputID} does not have a identifier.");
|
||||
identifier = "unkown";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(label))
|
||||
{
|
||||
Debug.LogWarning($"Output {outputID} does not have a label.");
|
||||
label = "unkown";
|
||||
}
|
||||
|
||||
return new SubstanceOutputDescription()
|
||||
{
|
||||
Identifier = identifier,
|
||||
Label = label,
|
||||
Index = (int)inputDesc.mIndex,
|
||||
Type = inputDesc.mValueType.ToUnity(),
|
||||
Channel = channel
|
||||
};
|
||||
}
|
||||
|
||||
public SubstanceOutputDescription CreateVirtualOutput(SubstanceVirtualOutputCreateInfo info)
|
||||
{
|
||||
var description = info.CreateOutputDesc();
|
||||
var format = info.CreateOutputFormat();
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_create_virtual_output(_handler, (IntPtr)_fileGraphID, ref description, ref format);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
var identifier = Marshal.PtrToStringAnsi(description.mIdentifier);
|
||||
var label = Marshal.PtrToStringAnsi(description.mIdentifier);
|
||||
var channel = Marshal.PtrToStringAnsi(description.mChannelUsage);
|
||||
|
||||
return new SubstanceOutputDescription()
|
||||
{
|
||||
Identifier = identifier,
|
||||
Label = label,
|
||||
Index = (int)description.mIndex,
|
||||
Type = description.mValueType.ToUnity(),
|
||||
Channel = channel,
|
||||
};
|
||||
}
|
||||
|
||||
public int CreateOutputCopy(int outputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_create_output_copy(_handler, (IntPtr)_fileGraphID, (IntPtr)outputID, out NativeOutputDesc inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
return (int)inputDesc.mIndex;
|
||||
}
|
||||
|
||||
public uint GetOutputUID(int outputIndex)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_output_uid(_handler, (IntPtr)_fileGraphID, (IntPtr)outputIndex, out IntPtr outputUID);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
return (uint)outputUID;
|
||||
}
|
||||
|
||||
public void AssignOutputToAlphaChannel(int targetOutputID, int alphaChannelID, bool invert = false)
|
||||
{
|
||||
float minValue = invert ? 1f : 0f;
|
||||
float maxValue = invert ? 0f : 1f;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_assign_as_alpha_channel(_handler, (IntPtr)_fileGraphID, (IntPtr)targetOutputID, (IntPtr)alphaChannelID, minValue, maxValue);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
public void ResetAlphaChannelAssignment(int targetOutputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_output_desc(_handler, (IntPtr)_fileGraphID, (IntPtr)targetOutputID, out NativeOutputDesc outputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
result = (ErrorCode)NativeMethods.sbsario_sbsar_get_output_format_override(_handler, (IntPtr)_fileGraphID, (IntPtr)targetOutputID, out IntPtr isFormatOverridenPtr, out NativeOutputFormat oldFormat);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
bool isFormatOverriden = (int)isFormatOverridenPtr != 0;
|
||||
|
||||
if (!isFormatOverriden)
|
||||
return;
|
||||
|
||||
if (oldFormat.format == NativeConsts.UseDefault)
|
||||
return;
|
||||
|
||||
NativeOutputFormat newFormat = oldFormat;
|
||||
newFormat.format = NativeConsts.UseDefault;
|
||||
|
||||
result = (ErrorCode)NativeMethods.sbsario_sbsar_set_output_format_override(_handler, (IntPtr)_fileGraphID, (IntPtr)targetOutputID, ref newFormat);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
public void ChangeOutputRBChannels(int targetOutputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_output_format_override(_handler, (IntPtr)_fileGraphID, (IntPtr)targetOutputID, out IntPtr isFormatOverridenPtr, out NativeOutputFormat oldFormat);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
bool isFormatOverriden = (int)isFormatOverridenPtr != 0;
|
||||
|
||||
NativeOutputFormat newFormat = NativeOutputFormat.CreateDefault();
|
||||
|
||||
if (isFormatOverriden)
|
||||
newFormat = oldFormat;
|
||||
|
||||
var redChannel = newFormat.ChannelComponent0;
|
||||
var blueChannel = newFormat.ChannelComponent2;
|
||||
|
||||
if (blueChannel.outputIndex == NativeConsts.UseDefault || redChannel.outputIndex == NativeConsts.UseDefault)
|
||||
return;
|
||||
|
||||
if (newFormat.ChannelComponent0.ShuffleIndex == ShuffleIndex.Blue &&
|
||||
newFormat.ChannelComponent2.ShuffleIndex == ShuffleIndex.Red)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
newFormat.ChannelComponent0.ShuffleIndex = ShuffleIndex.Blue;
|
||||
newFormat.ChannelComponent2.ShuffleIndex = ShuffleIndex.Red;
|
||||
|
||||
result = (ErrorCode)NativeMethods.sbsario_sbsar_set_output_format_override(_handler, (IntPtr)_fileGraphID, (IntPtr)targetOutputID, ref newFormat);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
#endregion Output
|
||||
|
||||
#region Input
|
||||
|
||||
/// <summary>
|
||||
/// Get the total input count for a given graph in the substance object.
|
||||
/// </summary>
|
||||
/// <returns>Total graph input count.</returns>
|
||||
public int GetInputCount()
|
||||
{
|
||||
return (int)NativeMethods.sbsario_sbsar_get_input_count(_handler, (IntPtr)_fileGraphID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the input object for a given graph in the substance object.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <returns>Substance input object.</returns>
|
||||
public SubstanceInputBase GetInputObject(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
if (result == ErrorCode.SBSARIO_ERROR_FAILURE)
|
||||
{
|
||||
Debug.LogWarning($"Unable to load input from graphID: {_fileGraphID} and inputID:{inputID}. The input type is not supported.");
|
||||
return SubstanceInputFactory.CreateInvalidInput(inputID);
|
||||
}
|
||||
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
var input = SubstanceInputFactory.CreateInput(inputDesc);
|
||||
AssignInputDescription(inputID, input);
|
||||
return input;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the target input should be visible in the editor.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Target input ID.</param>
|
||||
/// <returns>True if the target input should be visible in the editor.</returns>
|
||||
public bool IsInputVisible(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input_visibility(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeInputVisibility visibility);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
return (int)visibility.IsVisible == 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a float input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="value">Input value.</param>
|
||||
public void SetInputFloat(int inputID, float value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_FLOAT;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mFloatData0 = value;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a float2 input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="value">Input value.</param>
|
||||
public void SetInputFloat2(int inputID, Vector2 value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_FLOAT2;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mFloatData0 = value.x;
|
||||
inputData.Data.mFloatData1 = value.y;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a float3 input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="value">Input value.</param>
|
||||
public void SetInputFloat3(int inputID, Vector3 value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_FLOAT3;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mFloatData0 = value.x;
|
||||
inputData.Data.mFloatData1 = value.y;
|
||||
inputData.Data.mFloatData2 = value.z;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a float4 input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="value">Input value.</param>
|
||||
public void SetInputFloat4(int inputID, Vector4 value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_FLOAT4;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mFloatData0 = value.x;
|
||||
inputData.Data.mFloatData1 = value.y;
|
||||
inputData.Data.mFloatData2 = value.z;
|
||||
inputData.Data.mFloatData3 = value.w;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a int input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="value">Input value.</param>
|
||||
public void SetInputInt(int inputID, int value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_INT;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mIntData0 = value;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a int2 input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="value">Input value.</param>
|
||||
public void SetInputInt2(int inputID, Vector2Int value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_INT2;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mIntData0 = value.x;
|
||||
inputData.Data.mIntData1 = value.y;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a int3 input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="value">Input value.</param>
|
||||
public void SetInputInt3(int inputID, Vector3Int value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_INT3;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mIntData0 = value.x;
|
||||
inputData.Data.mIntData1 = value.y;
|
||||
inputData.Data.mIntData2 = value.z;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a int4 input.
|
||||
/// </summary>
|
||||
/// <param name="inputID">Input index.</param>
|
||||
/// <param name="x">Input x value.</param>
|
||||
/// <param name="y">Input y value.</param>
|
||||
/// <param name="z">Input z value.</param>
|
||||
/// <param name="w">Input w value.</param>
|
||||
public void SetInputInt4(int inputID, int x, int y, int z, int w)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_INT4;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mIntData0 = x;
|
||||
inputData.Data.mIntData1 = y;
|
||||
inputData.Data.mIntData2 = z;
|
||||
inputData.Data.mIntData3 = w;
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInputString(int inputID, string value)
|
||||
{
|
||||
NativeData inputData = new NativeData();
|
||||
inputData.DataType = DataType.SBSARIO_DATA_INPUT;
|
||||
inputData.ValueType = ValueType.SBSARIO_VALUE_STRING;
|
||||
inputData.Index = (IntPtr)inputID;
|
||||
inputData.Data = new DataInternalNumeric();
|
||||
inputData.Data.mPtr = Marshal.StringToHGlobalAnsi(value);
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInputTexture2DNull(int inputID)
|
||||
{
|
||||
var imageData = new NativeDataImage
|
||||
{
|
||||
channel_order = ChannelOrder.SBSARIO_CHANNEL_ORDER_RGBA,
|
||||
height = IntPtr.Zero,
|
||||
width = IntPtr.Zero
|
||||
};
|
||||
|
||||
var numericData = new DataInternalNumeric
|
||||
{
|
||||
ImageData = imageData
|
||||
};
|
||||
|
||||
NativeData inputData = new NativeData
|
||||
{
|
||||
DataType = DataType.SBSARIO_DATA_INPUT,
|
||||
ValueType = ValueType.SBSARIO_VALUE_IMAGE,
|
||||
Index = (IntPtr)inputID,
|
||||
Data = numericData
|
||||
};
|
||||
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInputTexture2D(int inputID, Color32[] pixelData, int width, int height)
|
||||
{
|
||||
if (pixelData == null)
|
||||
return;
|
||||
|
||||
Color32[] flippedData = TextureExtensions.FlipY(pixelData, width, height);
|
||||
byte[] textureBytes = TextureExtensions.Color32ArrayToByteArray(flippedData);
|
||||
int textureSize = Marshal.SizeOf(textureBytes[0]) * textureBytes.Length;
|
||||
IntPtr tempNativeMemory = Marshal.AllocHGlobal(textureSize);
|
||||
Marshal.Copy(textureBytes, 0, tempNativeMemory, textureBytes.Length);
|
||||
|
||||
var imageData = new NativeDataImage
|
||||
{
|
||||
channel_order = ChannelOrder.SBSARIO_CHANNEL_ORDER_RGBA,
|
||||
height = (IntPtr)width,
|
||||
width = (IntPtr)height,
|
||||
mipmaps = (IntPtr)0,
|
||||
image_format = TextureFormat.RGBA32.ToSubstance(),
|
||||
data = tempNativeMemory
|
||||
};
|
||||
|
||||
var numericData = new DataInternalNumeric
|
||||
{
|
||||
ImageData = imageData
|
||||
};
|
||||
|
||||
NativeData inputData = new NativeData
|
||||
{
|
||||
DataType = DataType.SBSARIO_DATA_INPUT,
|
||||
ValueType = ValueType.SBSARIO_VALUE_IMAGE,
|
||||
Index = (IntPtr)inputID,
|
||||
Data = numericData
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_set_input(_handler, (IntPtr)_fileGraphID, ref inputData);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to update Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(tempNativeMemory);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetInputFloat(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return inputDesc.Data.mFloatData0;
|
||||
}
|
||||
|
||||
public Vector2 GetInputFloat2(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return new Vector2(inputDesc.Data.mFloatData0, inputDesc.Data.mFloatData1);
|
||||
}
|
||||
|
||||
public Vector3 GetInputFloat3(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return new Vector3(inputDesc.Data.mFloatData0, inputDesc.Data.mFloatData1, inputDesc.Data.mFloatData2);
|
||||
}
|
||||
|
||||
public Vector4 GetInputFloat4(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return new Vector4(inputDesc.Data.mFloatData0, inputDesc.Data.mFloatData1, inputDesc.Data.mFloatData2, inputDesc.Data.mFloatData2);
|
||||
}
|
||||
|
||||
public int GetInputInt(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return inputDesc.Data.mIntData0;
|
||||
}
|
||||
|
||||
public Vector2Int GetInputInt2(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return new Vector2Int(inputDesc.Data.mIntData0, inputDesc.Data.mIntData1);
|
||||
}
|
||||
|
||||
public Vector3Int GetInputInt3(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return new Vector3Int(inputDesc.Data.mIntData0, inputDesc.Data.mIntData1, inputDesc.Data.mIntData2);
|
||||
}
|
||||
|
||||
public int[] GetInputInt4(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return new int[] { inputDesc.Data.mIntData0, inputDesc.Data.mIntData1, inputDesc.Data.mIntData2, inputDesc.Data.mIntData2 };
|
||||
}
|
||||
|
||||
public string GetInputString(int inputID)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeData inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input {inputID} for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return Marshal.PtrToStringAnsi(inputDesc.Data.mPtr);
|
||||
}
|
||||
|
||||
#endregion Input
|
||||
|
||||
public IntPtr GetNativeHandle()
|
||||
{
|
||||
return _handler;
|
||||
}
|
||||
|
||||
public int GetFileGraphID()
|
||||
{
|
||||
return _fileGraphID;
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposedValue)
|
||||
{
|
||||
if (_handler != default)
|
||||
{
|
||||
NativeMethods.sbsario_sbsar_close(_handler);
|
||||
_handler = default;
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
~SubstanceNativeGraph()
|
||||
{
|
||||
Dispose(disposing: false);
|
||||
}
|
||||
|
||||
#endregion IDisposable
|
||||
|
||||
private void AssignInputDescription(int inputID, SubstanceInputBase input)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_input_desc(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeInputDesc inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
var identifier = inputDesc.mIdentifier == default ? null : Marshal.PtrToStringAnsi(inputDesc.mIdentifier);
|
||||
var label = inputDesc.mLabel == default ? null : Marshal.PtrToStringAnsi(inputDesc.mLabel);
|
||||
var guiGroup = inputDesc.GuiGroup == default ? null : Marshal.PtrToStringAnsi(inputDesc.GuiGroup);
|
||||
var guiDescription = inputDesc.GuiDescription == default ? null : Marshal.PtrToStringAnsi(inputDesc.GuiDescription);
|
||||
|
||||
input.Description = new SubstanceInputDescription()
|
||||
{
|
||||
Identifier = identifier,
|
||||
Label = label,
|
||||
GuiGroup = guiGroup,
|
||||
GuiDescription = guiDescription,
|
||||
Type = ((ValueType)inputDesc.mValueType).ToUnity(),
|
||||
WidgetType = ((WidgetType)inputDesc.inputWidgetType).ToUnity()
|
||||
};
|
||||
|
||||
if (input.IsNumeric)
|
||||
AssignNumericInputDescription(inputID, input);
|
||||
}
|
||||
|
||||
private void AssignNumericInputDescription(int inputID, SubstanceInputBase substanceInput)
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_numeric_input_desc(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, out NativeNumericInputDesc inputDesc);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
throw new SubstanceException(result);
|
||||
|
||||
substanceInput.SetNumericDescription(inputDesc);
|
||||
|
||||
if ((int)(inputDesc.enumValueCount) != 0)
|
||||
{
|
||||
var count = (int)inputDesc.enumValueCount;
|
||||
|
||||
NativeEnumInputDesc[] buffer = new NativeEnumInputDesc[count];
|
||||
GCHandle gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
||||
IntPtr pointer = gcHandle.AddrOfPinnedObject();
|
||||
|
||||
try
|
||||
{
|
||||
result = (ErrorCode)NativeMethods.sbsario_sbsar_get_enum_input_desc(_handler, (IntPtr)_fileGraphID, (IntPtr)inputID, pointer, inputDesc.enumValueCount);
|
||||
substanceInput.SetEnumOptions(buffer);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError("Unable to get data for enum.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
gcHandle.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetPhysicalSize()
|
||||
{
|
||||
ErrorCode result = (ErrorCode)NativeMethods.sbsario_sbsar_get_physical_size(_handler, (IntPtr)_fileGraphID, out NativePhysicalSize nativePhysicalSize);
|
||||
|
||||
if (result != ErrorCode.SBSARIO_ERROR_OK)
|
||||
{
|
||||
Debug.LogError($"Fail to get Substance input physical size for graph {_fileGraphID}");
|
||||
throw new SubstanceException(result);
|
||||
}
|
||||
|
||||
return new Vector3(nativePhysicalSize.X, nativePhysicalSize.Y, nativePhysicalSize.Z);
|
||||
}
|
||||
}
|
||||
} // namespace Adobe.Substance
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 497917f7329a849dc8e059ad36608990
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bf461d4804d46f47ba6d17adac26bfd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1b7ac5a63cb24c4a8b836efecf5b432
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
public enum ShuffleIndex
|
||||
{
|
||||
Red = 0,
|
||||
Green = 1,
|
||||
Blue = 2,
|
||||
AlphaChannel = 3
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19b7748e2fed01745849ab203806a4da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
/// <summary>
|
||||
/// Types of values supported by the substance Engine.
|
||||
/// </summary>
|
||||
public enum SubstanceValueType : uint
|
||||
{
|
||||
Float,
|
||||
Float2,
|
||||
Float3,
|
||||
Float4,
|
||||
Int,
|
||||
Int2,
|
||||
Int3,
|
||||
Int4,
|
||||
Image,
|
||||
String,
|
||||
Font,
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e3e8edcd045aa4439639e4dd4a876e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents different types of widgets used to assign input values.
|
||||
/// </summary>
|
||||
public enum SubstanceWidgetType
|
||||
{
|
||||
NoWidget,
|
||||
Slider,
|
||||
Angle,
|
||||
Color,
|
||||
ToggleButton,
|
||||
ComboBox,
|
||||
Image,
|
||||
Position
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73d408e59cbb3044e807be21f8dce834
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
public enum TextureFlip
|
||||
{
|
||||
None = 0x0,
|
||||
Horizontal = 0x1,
|
||||
Vertical = 0x2,
|
||||
Both = 0x3
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01ed99cadd094f841b47e95378e7d415
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d0e13b745090064e9c7e0bbd2b23b47
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d3285958facb6f44b410e1c81fa19c1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance
|
||||
{
|
||||
public interface ISubstanceInputDescNumerical
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6c5115cae5711a46a6d74d20391cfb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
/// <summary>
|
||||
/// Numeric input description for input of type float.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalFloat : ISubstanceInputDescNumerical
|
||||
{
|
||||
/// <summary>
|
||||
/// Default input value
|
||||
/// </summary>
|
||||
public float DefaultValue;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum value (UI hint only)
|
||||
/// </summary>
|
||||
public float MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum value (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public float MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Slider step size (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public float SliderStep;
|
||||
|
||||
/// <summary>
|
||||
/// Should the slider clamp the value? (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public bool SliderClamp;
|
||||
|
||||
/// <summary>
|
||||
/// Number of enum option for this value.
|
||||
/// </summary>
|
||||
public int EnumValueCount;
|
||||
|
||||
/// <summary>
|
||||
/// Array of enum values for this property. Only relevant if widget is SBSARIO_WIDGET_COMBOBOX (UI hint only).
|
||||
/// </summary>
|
||||
public SubstanceFloatEnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceFloatEnumOption
|
||||
{
|
||||
public float Value;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17cc9d69d9e234541a84546059a02135
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
/// <summary>
|
||||
/// Numeric input description for input of type float 2.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalFloat2 : ISubstanceInputDescNumerical
|
||||
{
|
||||
/// <summary>
|
||||
/// Default input value
|
||||
/// </summary>
|
||||
public Vector2 DefaultValue;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum value (UI hint only)
|
||||
/// </summary>
|
||||
public Vector2 MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum value (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public Vector2 MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Slider step size (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public float SliderStep;
|
||||
|
||||
/// <summary>
|
||||
/// Should the slider clamp the value? (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public bool SliderClamp;
|
||||
|
||||
/// <summary>
|
||||
/// Number of enum option for this value.
|
||||
/// </summary>
|
||||
public int EnumValueCount;
|
||||
|
||||
/// <summary>
|
||||
/// Array of enum values for this property. Only relevant if widget is SBSARIO_WIDGET_COMBOBOX (UI hint only).
|
||||
/// </summary>
|
||||
public SubstanceFloat2EnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceFloat2EnumOption
|
||||
{
|
||||
public Vector2 Value;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cd3bc40ad7c1cc41bc69189c63590b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
/// <summary>
|
||||
/// Numeric input description for input of type float3.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalFloat3 : ISubstanceInputDescNumerical
|
||||
{
|
||||
/// <summary>
|
||||
/// Default input value
|
||||
/// </summary>
|
||||
public Vector3 DefaultValue;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum value (UI hint only)
|
||||
/// </summary>
|
||||
public Vector3 MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum value (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public Vector3 MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Slider step size (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public float SliderStep;
|
||||
|
||||
/// <summary>
|
||||
/// Should the slider clamp the value? (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public bool SliderClamp;
|
||||
|
||||
/// <summary>
|
||||
/// Number of enum option for this value.
|
||||
/// </summary>
|
||||
public int EnumValueCount;
|
||||
|
||||
/// <summary>
|
||||
/// Array of enum values for this property. Only relevant if widget is SBSARIO_WIDGET_COMBOBOX (UI hint only).
|
||||
/// </summary>
|
||||
public SubstanceFloat3EnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceFloat3EnumOption
|
||||
{
|
||||
public Vector3 Value;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95d340e6db1018d4888654b6d6e4bfbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
/// <summary>
|
||||
/// Numeric input description for input of type float4.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalFloat4 : ISubstanceInputDescNumerical
|
||||
{
|
||||
/// <summary>
|
||||
/// Default input value
|
||||
/// </summary>
|
||||
public Vector4 DefaultValue;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum value (UI hint only)
|
||||
/// </summary>
|
||||
public Vector4 MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum value (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public Vector4 MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Slider step size (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public float SliderStep;
|
||||
|
||||
/// <summary>
|
||||
/// Should the slider clamp the value? (UI hint only) (Only relevant if widget is Input_Slider)
|
||||
/// </summary>
|
||||
public bool SliderClamp;
|
||||
|
||||
/// <summary>
|
||||
/// Number of enum option for this value.
|
||||
/// </summary>
|
||||
public int EnumValueCount;
|
||||
|
||||
/// <summary>
|
||||
/// Array of enum values for this property. Only relevant if widget is SBSARIO_WIDGET_COMBOBOX (UI hint only).
|
||||
/// </summary>
|
||||
public SubstanceFloat4EnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceFloat4EnumOption
|
||||
{
|
||||
public Vector4 Value;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b59f3763c24dd4b489b67cbf059c97e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
/// <summary>
|
||||
/// Numeric input description for input of type int.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalInt : ISubstanceInputDescNumerical
|
||||
{
|
||||
/// <summary>
|
||||
/// Default input value
|
||||
/// </summary>
|
||||
public int DefaultValue;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum value (UI hint only)
|
||||
/// </summary>
|
||||
public int MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum value. Only relevant if widget is Slider (UI hint only)
|
||||
/// </summary>
|
||||
public int MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Slider step size. Only relevant if widget is Slider (UI hint only).
|
||||
/// </summary>
|
||||
public float SliderStep;
|
||||
|
||||
/// <summary>
|
||||
/// True if the slider value is clamped. Only relevant if widget is Slider (UI hint only)
|
||||
/// </summary>
|
||||
public bool SliderClamp;
|
||||
|
||||
/// <summary>
|
||||
/// If non-empty, the labels to use for False (unchecked) and True (checked) values. Only relevant if widget is Input_Togglebutton
|
||||
/// </summary>
|
||||
public string LabelFalse;
|
||||
|
||||
public string LabelTrue;
|
||||
|
||||
/// <summary>
|
||||
/// Number of enum option for this value.
|
||||
/// </summary>
|
||||
public int EnumValueCount;
|
||||
|
||||
/// <summary>
|
||||
/// Array of enum values for this property. Only relevant if widget is SBSARIO_WIDGET_COMBOBOX (UI hint only).
|
||||
/// </summary>
|
||||
public SubstanceIntEnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceIntEnumOption
|
||||
{
|
||||
public int Value;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4505bd299acddfa42a93618bb3eb3144
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
/// <summary>
|
||||
/// Numeric input description for input of type int2.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalInt2 : ISubstanceInputDescNumerical
|
||||
{
|
||||
/// <summary>
|
||||
/// Default input value
|
||||
/// </summary>
|
||||
public Vector2Int DefaultValue;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum value (UI hint only)
|
||||
/// </summary>
|
||||
public Vector2Int MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum value. Only relevant if widget is Slider (UI hint only)
|
||||
/// </summary>
|
||||
public Vector2Int MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// True if the slider value is clamped. Only relevant if widget is Slider (UI hint only)
|
||||
/// </summary>
|
||||
public bool SliderClamp;
|
||||
|
||||
/// <summary>
|
||||
/// Number of enum option for this value.
|
||||
/// </summary>
|
||||
public int EnumValueCount;
|
||||
|
||||
/// <summary>
|
||||
/// Array of enum values for this property. Only relevant if widget is ComboBox (UI hint only).
|
||||
/// </summary>
|
||||
public SubstanceInt2EnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceInt2EnumOption
|
||||
{
|
||||
public Vector2Int Value;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f227c26b9ad4bc144b20f140676c3d39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalInt3 : ISubstanceInputDescNumerical
|
||||
{
|
||||
public Vector3Int DefaultValue;
|
||||
|
||||
public Vector3Int MinValue;
|
||||
|
||||
public Vector3Int MaxValue;
|
||||
|
||||
public Vector3Int SliderStep;
|
||||
|
||||
public bool SliderClamp;
|
||||
|
||||
public int EnumValueCount;
|
||||
|
||||
public SubstanceInt3EnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceInt3EnumOption
|
||||
{
|
||||
public Vector3Int Value;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36e74c56f6c8da5478de4fa824d907ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescNumericalInt4 : ISubstanceInputDescNumerical
|
||||
{
|
||||
public int DefaultValue0;
|
||||
public int DefaultValue1;
|
||||
public int DefaultValue2;
|
||||
public int DefaultValue3;
|
||||
|
||||
public int MinValue0;
|
||||
public int MinValue1;
|
||||
public int MinValue2;
|
||||
public int MinValue3;
|
||||
|
||||
public int MaxValue0;
|
||||
public int MaxValue1;
|
||||
public int MaxValue2;
|
||||
public int MaxValue3;
|
||||
|
||||
public int SliderStep0;
|
||||
public int SliderStep1;
|
||||
public int SliderStep2;
|
||||
public int SliderStep3;
|
||||
|
||||
public bool SliderClamp;
|
||||
|
||||
public int EnumValueCount;
|
||||
|
||||
public SubstanceInt4EnumOption[] EnumValues;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubstanceInt4EnumOption
|
||||
{
|
||||
public int Value0;
|
||||
public int Value1;
|
||||
public int Value2;
|
||||
public int Value3;
|
||||
|
||||
public string Label;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ba763c16c13298419198087a5b6db66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input.Description
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputDescription
|
||||
{
|
||||
public string Identifier;
|
||||
|
||||
public string Label;
|
||||
|
||||
public string GuiGroup;
|
||||
|
||||
public string GuiDescription;
|
||||
|
||||
public SubstanceValueType Type;
|
||||
|
||||
public SubstanceWidgetType WidgetType;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc6a243b92a09374d89b9c500fffa0e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,117 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Adobe.Substance.Input.Description;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
public interface ISubstanceInput
|
||||
{
|
||||
int Index { get; }
|
||||
|
||||
SubstanceValueType ValueType { get; }
|
||||
|
||||
bool IsNumeric { get; }
|
||||
|
||||
bool IsValid { get; }
|
||||
SubstanceInputDescription Description { get; }
|
||||
|
||||
void UpdateNativeHandle(SubstanceNativeGraph handler);
|
||||
|
||||
internal void SetNumericDescription(NativeNumericInputDesc desc);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns the native enum data from the substance engine to the numerical input description (Only valid if input is numeric)
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
internal void SetEnumOptions(NativeEnumInputDesc[] options);
|
||||
|
||||
bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for representing all the different types of substance graph inputs.
|
||||
/// </summary>
|
||||
public abstract class SubstanceInputBase : ISubstanceInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Input index inside the Substance Graph.
|
||||
/// </summary>
|
||||
public int Index;
|
||||
|
||||
/// <summary>
|
||||
/// Input type.
|
||||
/// </summary>
|
||||
public abstract SubstanceValueType ValueType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if this input is numeric.
|
||||
/// </summary>
|
||||
public abstract bool IsNumeric { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if this input is supported by the Unity plugin.
|
||||
/// </summary>
|
||||
public abstract bool IsValid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Description with aditional information about the input.
|
||||
/// </summary>
|
||||
public SubstanceInputDescription Description;
|
||||
|
||||
/// <summary>
|
||||
/// Updates the native side of the substance engine with the current value for this input.
|
||||
/// </summary>
|
||||
/// <param name="handler"></param>
|
||||
public virtual void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assigns the native data from the substance engine to the numerical input description (Only valid if input is numeric)
|
||||
/// </summary>
|
||||
/// <param name="desc"></param>
|
||||
internal virtual void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assigns the native enum data from the substance engine to the numerical input description (Only valid if input is numeric)
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
internal virtual void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
}
|
||||
|
||||
#region ISubstanceInput
|
||||
|
||||
int ISubstanceInput.Index => Index;
|
||||
|
||||
SubstanceInputDescription ISubstanceInput.Description => Description;
|
||||
|
||||
SubstanceValueType ISubstanceInput.ValueType => ValueType;
|
||||
|
||||
bool ISubstanceInput.IsNumeric => IsNumeric;
|
||||
|
||||
bool ISubstanceInput.IsValid => IsValid;
|
||||
|
||||
void ISubstanceInput.SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
SetNumericDescription(desc);
|
||||
}
|
||||
|
||||
void ISubstanceInput.SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
SetEnumOptions(options);
|
||||
}
|
||||
|
||||
#endregion ISubstanceInput
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82a826b2d9a131a4598c52e033409dae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Static factory for creating Unity input object from native data.
|
||||
/// </summary>
|
||||
public static class SubstanceInputFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a unity data object from native substance data.
|
||||
/// </summary>
|
||||
/// <param name="nativeData">Native data.</param>
|
||||
/// <returns>Instance of a substance input interface object.</returns>
|
||||
internal static SubstanceInputBase CreateInput(NativeData nativeData)
|
||||
{
|
||||
int index = (int)nativeData.Index;
|
||||
DataInternalNumeric data = nativeData.Data;
|
||||
|
||||
switch (nativeData.ValueType)
|
||||
{
|
||||
case ValueType.SBSARIO_VALUE_FLOAT:
|
||||
return new SubstanceInputFloat(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_FLOAT2:
|
||||
return new SubstanceInputFloat2(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_FLOAT3:
|
||||
return new SubstanceInputFloat3(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_FLOAT4:
|
||||
return new SubstanceInputFloat4(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_INT:
|
||||
return new SubstanceInputInt(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_INT2:
|
||||
return new SubstanceInputInt2(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_INT3:
|
||||
return new SubstanceInputInt3(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_INT4:
|
||||
return new SubstanceInputInt4(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_IMAGE:
|
||||
return new SubstanceInputTexture(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_STRING:
|
||||
return new SubstanceInputString(index, data);
|
||||
|
||||
case ValueType.SBSARIO_VALUE_FONT:
|
||||
return new SubstanceInputFont(index, data);
|
||||
|
||||
default:
|
||||
throw new System.InvalidOperationException($"Can not create unity type from native data for type {nativeData.ValueType}.");
|
||||
}
|
||||
}
|
||||
|
||||
internal static SubstanceInputBase CreateInvalidInput(int inputID)
|
||||
{
|
||||
return new SubstanceInvalidInput(inputID);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb4c90b1beaaf634092abf47829fe011
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a314bf34bf71b50468f5d639e47d5c14
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,71 @@
|
||||
using Adobe.Substance.Input.Description;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[Serializable]
|
||||
public class SubstanceInputFloat : SubstanceInputBase
|
||||
{
|
||||
public float Data;
|
||||
|
||||
public SubstanceInputDescNumericalFloat NumericalDescription;
|
||||
|
||||
public override bool IsNumeric => true;
|
||||
public override bool IsValid => true;
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Float;
|
||||
|
||||
internal SubstanceInputFloat(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = data.mFloatData0;
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
handler.SetInputFloat(Index, Data);
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
NumericalDescription = new SubstanceInputDescNumericalFloat
|
||||
{
|
||||
DefaultValue = desc.default_value.mFloatData0,
|
||||
MaxValue = desc.max_value.mFloatData0,
|
||||
MinValue = desc.min_value.mFloatData0,
|
||||
SliderClamp = Convert.ToBoolean(desc.sliderClamp.ToInt32()),
|
||||
SliderStep = desc.sliderStep,
|
||||
EnumValueCount = desc.enumValueCount.ToInt32()
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
NumericalDescription.EnumValues = new SubstanceFloatEnumOption[options.Length];
|
||||
|
||||
for (int i = 0; i < NumericalDescription.EnumValues.Length; i++)
|
||||
{
|
||||
var option = new SubstanceFloatEnumOption
|
||||
{
|
||||
Label = Marshal.PtrToStringAnsi(options[i].label),
|
||||
Value = options[i].value.mFloatData0
|
||||
};
|
||||
|
||||
NumericalDescription.EnumValues[i] = option;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public override bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = NumericalDescription;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a2b5e2d6e8627946aee84ca2cad43a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputFloat2 : SubstanceInputBase
|
||||
{
|
||||
public Vector2 Data;
|
||||
|
||||
public SubstanceInputDescNumericalFloat2 NumericalDescription;
|
||||
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Float2;
|
||||
public override bool IsNumeric => true;
|
||||
public override bool IsValid => true;
|
||||
|
||||
internal SubstanceInputFloat2(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = new Vector2(data.mFloatData0, data.mFloatData1);
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
handler.SetInputFloat2(Index, Data);
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
NumericalDescription = new SubstanceInputDescNumericalFloat2
|
||||
{
|
||||
DefaultValue = new Vector2(desc.default_value.mFloatData0, desc.default_value.mFloatData1),
|
||||
MaxValue = new Vector2(desc.max_value.mFloatData0, desc.max_value.mFloatData1),
|
||||
MinValue = new Vector2(desc.min_value.mFloatData0, desc.min_value.mFloatData1),
|
||||
SliderClamp = Convert.ToBoolean(desc.sliderClamp.ToInt32()),
|
||||
SliderStep = desc.sliderStep,
|
||||
EnumValueCount = desc.enumValueCount.ToInt32()
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
NumericalDescription.EnumValues = new SubstanceFloat2EnumOption[options.Length];
|
||||
|
||||
for (int i = 0; i < NumericalDescription.EnumValues.Length; i++)
|
||||
{
|
||||
var option = new SubstanceFloat2EnumOption
|
||||
{
|
||||
Label = Marshal.PtrToStringAnsi(options[i].label),
|
||||
Value = new Vector2(options[i].value.mFloatData0, options[i].value.mFloatData1)
|
||||
};
|
||||
|
||||
NumericalDescription.EnumValues[i] = option;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public override bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = NumericalDescription;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0c4e3cee5c04494089d8b2b921a09a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputFloat3 : SubstanceInputBase
|
||||
{
|
||||
public Vector3 Data;
|
||||
|
||||
public SubstanceInputDescNumericalFloat3 NumericalDescription;
|
||||
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Float3;
|
||||
public override bool IsNumeric => true;
|
||||
public override bool IsValid => true;
|
||||
|
||||
internal SubstanceInputFloat3(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = new Vector3(data.mFloatData0, data.mFloatData1, data.mFloatData2);
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
handler.SetInputFloat3(Index, Data);
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
NumericalDescription = new SubstanceInputDescNumericalFloat3
|
||||
{
|
||||
DefaultValue = new Vector3(desc.default_value.mFloatData0, desc.default_value.mFloatData1, desc.default_value.mFloatData2),
|
||||
MaxValue = new Vector3(desc.max_value.mFloatData0, desc.max_value.mFloatData1, desc.max_value.mFloatData2),
|
||||
MinValue = new Vector3(desc.min_value.mFloatData0, desc.min_value.mFloatData1, desc.min_value.mFloatData2),
|
||||
SliderClamp = Convert.ToBoolean(desc.sliderClamp.ToInt32()),
|
||||
SliderStep = desc.sliderStep,
|
||||
EnumValueCount = desc.enumValueCount.ToInt32()
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
NumericalDescription.EnumValues = new SubstanceFloat3EnumOption[options.Length];
|
||||
|
||||
for (int i = 0; i < NumericalDescription.EnumValues.Length; i++)
|
||||
{
|
||||
var option = new SubstanceFloat3EnumOption
|
||||
{
|
||||
Label = Marshal.PtrToStringAnsi(options[i].label),
|
||||
Value = new Vector3(options[i].value.mFloatData0, options[i].value.mFloatData1, options[i].value.mFloatData2)
|
||||
};
|
||||
|
||||
NumericalDescription.EnumValues[i] = option;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public override bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = NumericalDescription;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 972cacc8762922b4c899c029ca6f30ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputFloat4 : SubstanceInputBase
|
||||
{
|
||||
public Vector4 Data;
|
||||
|
||||
public SubstanceInputDescNumericalFloat4 NumericalDescription;
|
||||
|
||||
public override bool IsNumeric => true;
|
||||
public override bool IsValid => true;
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Float4;
|
||||
|
||||
internal SubstanceInputFloat4(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = new Vector4(data.mFloatData0, data.mFloatData1, data.mFloatData2, data.mFloatData3);
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
handler.SetInputFloat4(Index, Data);
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
NumericalDescription = new SubstanceInputDescNumericalFloat4
|
||||
{
|
||||
DefaultValue = new Vector4(desc.default_value.mFloatData0, desc.default_value.mFloatData1, desc.default_value.mFloatData2, desc.default_value.mFloatData3),
|
||||
MaxValue = new Vector4(desc.max_value.mFloatData0, desc.max_value.mFloatData1, desc.max_value.mFloatData2, desc.max_value.mFloatData3),
|
||||
MinValue = new Vector4(desc.min_value.mFloatData0, desc.min_value.mFloatData1, desc.min_value.mFloatData2, desc.min_value.mFloatData3),
|
||||
SliderClamp = Convert.ToBoolean(desc.sliderClamp.ToInt32()),
|
||||
SliderStep = desc.sliderStep,
|
||||
EnumValueCount = desc.enumValueCount.ToInt32()
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
NumericalDescription.EnumValues = new SubstanceFloat4EnumOption[options.Length];
|
||||
|
||||
for (int i = 0; i < NumericalDescription.EnumValues.Length; i++)
|
||||
{
|
||||
var option = new SubstanceFloat4EnumOption
|
||||
{
|
||||
Label = Marshal.PtrToStringAnsi(options[i].label),
|
||||
Value = new Vector4(options[i].value.mFloatData0, options[i].value.mFloatData1, options[i].value.mFloatData2, options[i].value.mFloatData3)
|
||||
};
|
||||
|
||||
NumericalDescription.EnumValues[i] = option;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public override bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = NumericalDescription;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38a7b8b2e997dce43af21e967aabeb90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputFont : SubstanceInputBase
|
||||
{
|
||||
public Font Data;
|
||||
public override bool IsValid => true;
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Font;
|
||||
public override bool IsNumeric => false;
|
||||
public ISubstanceInputDescNumerical NumericalDescription => null;
|
||||
|
||||
internal SubstanceInputFont(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = null;
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b54963e3fd7509d47a7807204ab5ad0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Adobe.Substance.Input.Description;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputInt : SubstanceInputBase
|
||||
{
|
||||
public int Data;
|
||||
|
||||
public SubstanceInputDescNumericalInt NumericalDescription;
|
||||
|
||||
public override bool IsValid => true;
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Int;
|
||||
public override bool IsNumeric => true;
|
||||
|
||||
internal SubstanceInputInt(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = data.mIntData0;
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
handler.SetInputInt(Index, Data);
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
NumericalDescription = new SubstanceInputDescNumericalInt
|
||||
{
|
||||
DefaultValue = desc.default_value.mIntData0,
|
||||
MaxValue = desc.max_value.mIntData0,
|
||||
MinValue = desc.min_value.mIntData0,
|
||||
SliderClamp = Convert.ToBoolean(desc.sliderClamp.ToInt32()),
|
||||
SliderStep = desc.sliderStep,
|
||||
EnumValueCount = desc.enumValueCount.ToInt32()
|
||||
};
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
NumericalDescription.EnumValues = new SubstanceIntEnumOption[options.Length];
|
||||
|
||||
for (int i = 0; i < NumericalDescription.EnumValues.Length; i++)
|
||||
{
|
||||
var option = new SubstanceIntEnumOption
|
||||
{
|
||||
Label = Marshal.PtrToStringAnsi(options[i].label),
|
||||
Value = options[i].value.mIntData0
|
||||
};
|
||||
|
||||
NumericalDescription.EnumValues[i] = option;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public override bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = NumericalDescription;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1601ac9007c2d7a40a34b1bb071fd814
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
using Adobe.Substance.Input.Description;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputInt2 : SubstanceInputBase
|
||||
{
|
||||
public Vector2Int Data;
|
||||
|
||||
public SubstanceInputDescNumericalInt2 NumericalDescription;
|
||||
|
||||
public override bool IsValid => true;
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Int2;
|
||||
public override bool IsNumeric => true;
|
||||
|
||||
internal SubstanceInputInt2(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = new Vector2Int(data.mIntData0, data.mIntData1);
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
handler.SetInputInt2(Index, Data);
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
NumericalDescription = new SubstanceInputDescNumericalInt2
|
||||
{
|
||||
DefaultValue = new Vector2Int(desc.default_value.mIntData0, desc.default_value.mIntData1),
|
||||
MaxValue = new Vector2Int(desc.max_value.mIntData0, desc.max_value.mIntData1),
|
||||
MinValue = new Vector2Int(desc.min_value.mIntData0, desc.min_value.mIntData1),
|
||||
SliderClamp = Convert.ToBoolean(desc.sliderClamp.ToInt32()),
|
||||
EnumValueCount = desc.enumValueCount.ToInt32()
|
||||
};
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
NumericalDescription.EnumValues = new SubstanceInt2EnumOption[options.Length];
|
||||
|
||||
for (int i = 0; i < NumericalDescription.EnumValues.Length; i++)
|
||||
{
|
||||
var option = new SubstanceInt2EnumOption
|
||||
{
|
||||
Label = Marshal.PtrToStringAnsi(options[i].label),
|
||||
Value = new Vector2Int(options[i].value.mIntData0, options[i].value.mIntData1)
|
||||
};
|
||||
|
||||
NumericalDescription.EnumValues[i] = option;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = NumericalDescription;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1edf95e7b56e87b43bf900d164c150b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,64 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Adobe.Substance.Input.Description;
|
||||
|
||||
namespace Adobe.Substance.Input
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SubstanceInputInt3 : SubstanceInputBase
|
||||
{
|
||||
public Vector3Int Data;
|
||||
|
||||
public SubstanceInputDescNumericalInt3 NumericalDescription;
|
||||
|
||||
public override bool IsValid => true;
|
||||
public override SubstanceValueType ValueType => SubstanceValueType.Int3;
|
||||
public override bool IsNumeric => true;
|
||||
|
||||
internal SubstanceInputInt3(int index, DataInternalNumeric data)
|
||||
{
|
||||
Index = index;
|
||||
Data = new Vector3Int(data.mIntData0, data.mIntData1, data.mIntData2);
|
||||
}
|
||||
|
||||
public override void UpdateNativeHandle(SubstanceNativeGraph handler)
|
||||
{
|
||||
handler.SetInputInt3(Index, Data);
|
||||
}
|
||||
|
||||
internal override void SetNumericDescription(NativeNumericInputDesc desc)
|
||||
{
|
||||
NumericalDescription = new SubstanceInputDescNumericalInt3
|
||||
{
|
||||
DefaultValue = new Vector3Int(desc.default_value.mIntData0, desc.default_value.mIntData1, desc.default_value.mIntData2),
|
||||
MaxValue = new Vector3Int(desc.max_value.mIntData0, desc.max_value.mIntData1, desc.max_value.mIntData2),
|
||||
MinValue = new Vector3Int(desc.min_value.mIntData0, desc.min_value.mIntData1, desc.min_value.mIntData2),
|
||||
SliderClamp = Convert.ToBoolean(desc.sliderClamp.ToInt32()),
|
||||
EnumValueCount = desc.enumValueCount.ToInt32()
|
||||
};
|
||||
}
|
||||
|
||||
internal override void SetEnumOptions(NativeEnumInputDesc[] options)
|
||||
{
|
||||
NumericalDescription.EnumValues = new SubstanceInt3EnumOption[options.Length];
|
||||
|
||||
for (int i = 0; i < NumericalDescription.EnumValues.Length; i++)
|
||||
{
|
||||
var option = new SubstanceInt3EnumOption
|
||||
{
|
||||
Label = Marshal.PtrToStringAnsi(options[i].label),
|
||||
Value = new Vector3Int(options[i].value.mIntData0, options[i].value.mIntData1, options[i].value.mIntData2)
|
||||
};
|
||||
|
||||
NumericalDescription.EnumValues[i] = option;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool TryGetNumericalDescription(out ISubstanceInputDescNumerical description)
|
||||
{
|
||||
description = NumericalDescription;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 920e7de597d6a3744b255c5fa47734d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user