1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-17 00:44:19 +00:00

Added support for building Unity native audio plugins on desktop platforms

This commit is contained in:
ed 2018-05-10 16:32:30 +01:00
parent 30f6206be9
commit 527625b699
32 changed files with 1599 additions and 53 deletions

View file

@ -7267,8 +7267,194 @@ static const unsigned char temp_binary_data_54[] =
const char* jucer_PIPTemplate_h = (const char*) temp_binary_data_54;
//================== colourscheme_dark.xml ==================
//================== jucer_UnityPluginGUIScript.cs ==================
static const unsigned char temp_binary_data_55[] =
"#if UNITY_EDITOR\n"
"\n"
"using UnityEditor;\n"
"using UnityEngine;\n"
"\n"
"using System.Collections.Generic;\n"
"using System.Runtime.InteropServices;\n"
"\n"
"public class %%plugin_name%%GUI : IAudioEffectPluginGUI\n"
"{\n"
" public override string Name { get { return \"%%plugin_name%%\"; } }\n"
" public override string Description { get { return \"%%plugin_description%%\"; } }\n"
" public override string Vendor { get { return \"%%plugin_vendor%%\"; } }\n"
"\n"
" //==============================================================================\n"
"\t[DllImport(\"%%plugin_name%%\")] static extern System.IntPtr getRenderCallback();\n"
"\n"
" [DllImport(\"%%plugin_name%%\")] static extern void unityInitialiseTexture (int id, System.IntPtr texture, int width, int height);\n"
"\n"
" [DllImport(\"%%plugin_name%%\")] static extern void unityMouseDown (int id, float x, float y, EventModifiers mods, int button);\n"
" [DllImport(\"%%plugin_name%%\")] static extern void unityMouseDrag (int id, float x, float y, EventModifiers mods, int button);\n"
" [DllImport(\"%%plugin_name%%\")] static extern void unityMouseUp (int id, float x, float y, EventModifiers mods);\n"
"\n"
" [DllImport(\"%%plugin_name%%\")] static extern void unityKeyEvent (int id, KeyCode code, EventModifiers mods, string name);\n"
"\n"
" [DllImport(\"%%plugin_name%%\")] static extern void unitySetScreenBounds (int id, float x, float y, float w, float h);\n"
"\n"
" //==============================================================================\n"
" private class PluginGUIInstance\n"
" {\n"
" public PluginGUIInstance (ref IAudioEffectPlugin plugin, int id)\n"
" {\n"
" instanceID = id;\n"
"\n"
" float[] arr;\n"
" plugin.GetFloatBuffer (\"Editor\", out arr, 1);\n"
" hasEditor = (arr[0] > 0.0f);\n"
" }\n"
"\n"
" public void repaint (Rect r)\n"
" { \n"
" Vector2 newScreenPosition = GUIUtility.GUIToScreenPoint (r.position);\n"
"\n"
" if (bounds != r \n"
" || screenPosition != newScreenPosition)\n"
" {\n"
" screenPosition = newScreenPosition;\n"
" bounds = r;\n"
"\n"
" unitySetScreenBounds (instanceID, screenPosition.x, screenPosition.y, bounds.width, bounds.height);\n"
" setupTexture();\n"
" }\n"
"\n"
"\t\t\tGL.IssuePluginEvent (getRenderCallback(), instanceID);\n"
"\n"
" texture.SetPixels32 (pixels);\n"
" texture.Apply();\n"
"\n"
" EditorGUI.DrawPreviewTexture (bounds, texture);\n"
" }\n"
"\n"
" public bool handleMouseEvent (EventType eventType)\n"
" {\n"
" Vector2 mousePos = Event.current.mousePosition;\n"
" EventModifiers mods = Event.current.modifiers;\n"
"\n"
" if (! bounds.Contains (mousePos))\n"
" return false;\n"
"\n"
" Vector2 relativePos = new Vector2 (mousePos.x - bounds.x, mousePos.y - bounds.y);\n"
"\n"
" if (eventType == EventType.MouseDown) \n"
" {\n"
" unityMouseDown (instanceID, relativePos.x, relativePos.y, mods, Event.current.button);\n"
" GUIUtility.hotControl = GUIUtility.GetControlID (FocusType.Passive);\n"
" }\n"
" else if (eventType == EventType.MouseUp)\n"
" {\n"
" unityMouseUp (instanceID, relativePos.x, relativePos.y, mods);\n"
" GUIUtility.hotControl = 0;\n"
" }\n"
" else if (eventType == EventType.MouseDrag) \n"
" {\n"
" unityMouseDrag (instanceID, relativePos.x, relativePos.y, mods, Event.current.button);\n"
" }\n"
"\n"
" Event.current.Use();\n"
"\n"
" return true;\n"
" }\n"
"\n"
" public void handleKeyEvent (EventType eventType)\n"
" {\n"
" if (eventType == EventType.KeyDown)\n"
" {\n"
" KeyCode code = Event.current.keyCode;\n"
"\n"
" if (code == KeyCode.None)\n"
" return;\n"
"\n"
" EventModifiers mods = Event.current.modifiers;\n"
"\n"
" unityKeyEvent (instanceID, code, mods, code.ToString());\n"
" }\n"
" }\n"
"\n"
" private void setupTexture()\n"
" {\n"
" if (pixelHandle.IsAllocated)\n"
" pixelHandle.Free();\n"
"\n"
" texture = new Texture2D ((int) bounds.width, (int) bounds.height, TextureFormat.ARGB32, false);\n"
"\n"
" pixels = texture.GetPixels32();\n"
" pixelHandle = GCHandle.Alloc (pixels, GCHandleType.Pinned);\n"
"\n"
" unityInitialiseTexture (instanceID, pixelHandle.AddrOfPinnedObject(), texture.width, texture.height);\n"
" }\n"
"\n"
" public int instanceID = -1;\n"
" public bool hasEditor;\n"
"\n"
" private Vector2 screenPosition;\n"
" private Rect bounds;\n"
"\n"
" private Texture2D texture;\n"
" private Color32[] pixels;\n"
" private GCHandle pixelHandle;\n"
" }\n"
" List<PluginGUIInstance> guis = new List<PluginGUIInstance>();\n"
"\n"
" private PluginGUIInstance getGUIInstanceForPlugin (ref IAudioEffectPlugin plugin)\n"
" {\n"
" float[] idArray;\n"
" plugin.GetFloatBuffer (\"ID\", out idArray, 1);\n"
"\n"
" int id = (int) idArray[0];\n"
"\n"
" for (int i = 0; i < guis.Count; ++i)\n"
" {\n"
" if (guis[i].instanceID == id)\n"
" return guis[i];\n"
" }\n"
"\n"
" PluginGUIInstance newInstance = new PluginGUIInstance (ref plugin, id);\n"
" guis.Add (newInstance);\n"
"\n"
" return guis[guis.Count - 1];\n"
" }\n"
"\n"
" //==============================================================================\n"
" public override bool OnGUI (IAudioEffectPlugin plugin)\n"
" {\n"
" PluginGUIInstance guiInstance = getGUIInstanceForPlugin (ref plugin);\n"
"\n"
" if (! guiInstance.hasEditor)\n"
" return true;\n"
"\n"
" float[] arr;\n"
" plugin.GetFloatBuffer (\"Size\", out arr, 6);\n"
"\n"
" Rect r = GUILayoutUtility.GetRect (arr[0], arr[1],\n"
" new GUILayoutOption[] { GUILayout.MinWidth (arr[2]), GUILayout.MinHeight (arr[3]),\n"
" GUILayout.MaxWidth (arr[4]), GUILayout.MaxHeight (arr[5]) });\n"
"\n"
" int controlID = GUIUtility.GetControlID (FocusType.Passive);\n"
" Event currentEvent = Event.current;\n"
" EventType currentEventType = currentEvent.GetTypeForControl (controlID);\n"
"\n"
" if (currentEventType == EventType.Repaint)\n"
" guiInstance.repaint (r);\n"
" else if (currentEvent.isMouse)\n"
" guiInstance.handleMouseEvent (currentEventType);\n"
" else if (currentEvent.isKey)\n"
" guiInstance.handleKeyEvent (currentEventType);\n"
"\n"
" return false;\n"
" }\n"
"}\n"
"\n"
"#endif";
const char* jucer_UnityPluginGUIScript_cs = (const char*) temp_binary_data_55;
//================== colourscheme_dark.xml ==================
static const unsigned char temp_binary_data_56[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
"\r\n"
"<COLOUR_SCHEME font=\"&lt;Monospaced&gt;; 13.0\">\r\n"
@ -7293,10 +7479,10 @@ static const unsigned char temp_binary_data_55[] =
" <COLOUR name=\"Error\" colour=\"FFE60000\"/>\r\n"
"</COLOUR_SCHEME>\r\n";
const char* colourscheme_dark_xml = (const char*) temp_binary_data_55;
const char* colourscheme_dark_xml = (const char*) temp_binary_data_56;
//================== colourscheme_light.xml ==================
static const unsigned char temp_binary_data_56[] =
static const unsigned char temp_binary_data_57[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
"\r\n"
"<COLOUR_SCHEME font=\"&lt;Monospaced&gt;; 13.0\">\r\n"
@ -7321,16 +7507,16 @@ static const unsigned char temp_binary_data_56[] =
" <COLOUR name=\"Error\" colour=\"ffcc0000\"/>\r\n"
"</COLOUR_SCHEME>\r\n";
const char* colourscheme_light_xml = (const char*) temp_binary_data_56;
const char* colourscheme_light_xml = (const char*) temp_binary_data_57;
//================== nothingtoseehere.txt ==================
static const unsigned char temp_binary_data_57[] =
static const unsigned char temp_binary_data_58[] =
"VUEtMTk3NTkzMTgtNA==";
const char* nothingtoseehere_txt = (const char*) temp_binary_data_57;
const char* nothingtoseehere_txt = (const char*) temp_binary_data_58;
//================== offlinepage.html ==================
static const unsigned char temp_binary_data_58[] =
static const unsigned char temp_binary_data_59[] =
"<html>\n"
" <head>\n"
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=11\">\n"
@ -7374,10 +7560,10 @@ static const unsigned char temp_binary_data_58[] =
" </body>\n"
"</html>";
const char* offlinepage_html = (const char*) temp_binary_data_58;
const char* offlinepage_html = (const char*) temp_binary_data_59;
//================== projucer_EULA.txt ==================
static const unsigned char temp_binary_data_59[] =
static const unsigned char temp_binary_data_60[] =
"\r\n"
"IMPORTANT NOTICE: PLEASE READ CAREFULLY BEFORE INSTALLING THE SOFTWARE:\r\n"
"\r\n"
@ -7541,10 +7727,10 @@ static const unsigned char temp_binary_data_59[] =
"\r\n"
"10.6. Please note that this License, its subject matter and its formation, are governed by English law. You and we both agree to that the courts of England and Wales will have exclusive jurisdiction.\r\n";
const char* projucer_EULA_txt = (const char*) temp_binary_data_59;
const char* projucer_EULA_txt = (const char*) temp_binary_data_60;
//================== RecentFilesMenuTemplate.nib ==================
static const unsigned char temp_binary_data_60[] =
static const unsigned char temp_binary_data_61[] =
{ 98,112,108,105,115,116,48,48,212,0,1,0,2,0,3,0,4,0,5,0,6,1,53,1,54,88,36,118,101,114,115,105,111,110,88,36,111,98,106,101,99,116,115,89,36,97,114,99,104,105,118,101,114,84,36,116,111,112,18,0,1,134,160,175,16,74,0,7,0,8,0,31,0,35,0,36,0,42,0,46,0,50,
0,53,0,57,0,74,0,77,0,78,0,86,0,87,0,97,0,112,0,113,0,114,0,119,0,120,0,121,0,124,0,128,0,129,0,132,0,143,0,144,0,145,0,149,0,153,0,162,0,163,0,164,0,169,0,173,0,180,0,181,0,182,0,185,0,192,0,193,0,200,0,201,0,208,0,209,0,216,0,217,0,224,0,225,0,226,
0,229,0,230,0,232,0,249,1,11,1,29,1,30,1,31,1,32,1,33,1,34,1,35,1,36,1,37,1,38,1,39,1,40,1,41,1,42,1,43,1,44,1,47,1,50,85,36,110,117,108,108,219,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,
@ -7581,7 +7767,7 @@ static const unsigned char temp_binary_data_60[] =
7,157,7,159,7,161,7,163,7,165,7,167,7,169,7,171,7,173,7,175,7,177,7,179,7,181,7,190,7,192,7,225,7,227,7,229,7,231,7,233,7,235,7,237,7,239,7,241,7,243,7,245,7,247,7,249,7,251,7,253,7,255,8,2,8,5,8,8,8,11,8,14,8,17,8,20,8,23,8,26,8,29,8,32,8,35,8,38,8,
41,8,44,8,53,8,55,8,56,8,65,8,67,8,68,8,77,8,92,8,97,8,115,8,120,8,134,0,0,0,0,0,0,2,2,0,0,0,0,0,0,1,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,136,0,0 };
const char* RecentFilesMenuTemplate_nib = (const char*) temp_binary_data_60;
const char* RecentFilesMenuTemplate_nib = (const char*) temp_binary_data_61;
const char* getNamedResource (const char* resourceNameUTF8, int& numBytes)
@ -7648,6 +7834,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes)
case 0xbc050edc: numBytes = 4926; return jucer_PIPAudioProcessorTemplate_h;
case 0xf4ca9e9a: numBytes = 2447; return jucer_PIPMain_cpp;
case 0x0b16e320: numBytes = 517; return jucer_PIPTemplate_h;
case 0xcd472557: numBytes = 6426; return jucer_UnityPluginGUIScript_cs;
case 0x763d39dc: numBytes = 1050; return colourscheme_dark_xml;
case 0xe8b08520: numBytes = 1050; return colourscheme_light_xml;
case 0x938e96ec: numBytes = 20; return nothingtoseehere_txt;
@ -7718,6 +7905,7 @@ const char* namedResourceList[] =
"jucer_PIPAudioProcessorTemplate_h",
"jucer_PIPMain_cpp",
"jucer_PIPTemplate_h",
"jucer_UnityPluginGUIScript_cs",
"colourscheme_dark_xml",
"colourscheme_light_xml",
"nothingtoseehere_txt",
@ -7783,6 +7971,7 @@ const char* originalFilenames[] =
"jucer_PIPAudioProcessorTemplate.h",
"jucer_PIPMain.cpp",
"jucer_PIPTemplate.h",
"jucer_UnityPluginGUIScript.cs",
"colourscheme_dark.xml",
"colourscheme_light.xml",
"nothingtoseehere.txt",