From 4e3b65a0e6648fc1a59e06c9b02666bcfccf20a5 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Sun, 6 Nov 2016 22:35:10 -0800 Subject: [PATCH 01/22] Added keyboard shortcuts and more context menu options - Added keyboard shortcuts: copy, cut, duplicate, delete, select all - Added context menu when right clicking on empty space: add block, paste - Context menus now appear on mouse up to better support panning --- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 230 +++++++++++++++--- 1 file changed, 200 insertions(+), 30 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index a0df30f9..b943fe9e 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -36,9 +36,15 @@ namespace Fungus.EditorUtils protected Texture2D addTexture; protected Rect selectionBox; - protected Vector2 startSelectionBoxPosition = new Vector2(-1.0f, -1.0f); + protected Vector2 startSelectionBoxPosition = -Vector2.one; protected List mouseDownSelectionState = new List(); + protected List copyList = new List(); + + // Context Click occurs on MouseDown which interferes with panning + // Track right click positions manually to show menus on MouseUp + protected Vector2 rightClickDown = -Vector2.one; + [MenuItem("Tools/Fungus/Flowchart Window")] static void Init() { @@ -61,6 +67,7 @@ namespace Fungus.EditorUtils nodeStyle.wordWrap = true; addTexture = Resources.Load("Icons/add_small") as Texture2D; + copyList.Clear(); } protected virtual void OnInspectorUpdate() @@ -156,6 +163,9 @@ namespace Fungus.EditorUtils if (isSelected) { + // Deselect + flowchart.SelectedBlocks.Remove(deleteBlock); + // Revert to showing properties for the Flowchart Selection.activeGameObject = flowchart.gameObject; } @@ -168,6 +178,9 @@ namespace Fungus.EditorUtils // Handle selection box events after block and overlay events HandleSelectionBox(flowchart); + ValidateCommands(flowchart); + ExecuteCommands(flowchart); + if (forceRepaintCount > 0) { // Redraw on next frame to get crisp refresh rate @@ -288,6 +301,19 @@ namespace Fungus.EditorUtils // Calc rect for script view Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.Zoom, this.position.height / flowchart.Zoom); + // Update right click start outside of EditorZoomArea + if (Event.current.button == 1) + { + if (Event.current.type == EventType.MouseDown) + { + rightClickDown = Event.current.mousePosition; + } + else if (Event.current.type == EventType.MouseDrag) + { + rightClickDown = -Vector2.one; + } + } + EditorZoomArea.Begin(flowchart.Zoom, scriptViewRect); DrawGrid(flowchart); @@ -296,7 +322,10 @@ namespace Fungus.EditorUtils // The center of the Flowchart depends on the block positions and window dimensions, so we calculate it // here in the FlowchartWindow class and store it on the Flowchart object for use later. - CalcFlowchartCenter(flowchart, blocks); + if (flowchart != null && blocks.Length > 0) + { + CalcFlowchartCenter(flowchart, blocks); + } // Draw connections foreach (var block in blocks) @@ -455,15 +484,63 @@ namespace Fungus.EditorUtils GLDraw.EndGroup(); EditorZoomArea.End(); + + // Handle right click up outside of EditorZoomArea to avoid strange offsets + if (Event.current.type == EventType.MouseUp && Event.current.button == 1 && + Event.current.mousePosition == rightClickDown && !mouseOverVariables) + { + var menu = new GenericMenu(); + var mousePosition = rightClickDown; + + Block hitBlock = null; + foreach (var block in blocks) + { + if (block._NodeRect.Contains(rightClickDown / flowchart.Zoom - flowchart.ScrollPos)) + { + hitBlock = block; + break; + } + } + // Clicked on a block + if (hitBlock != null) + { + flowchart.AddSelectedBlock(hitBlock); + + // Use a copy because flowchart.SelectedBlocks gets modified + var blockList = new List(flowchart.SelectedBlocks); + menu.AddItem(new GUIContent ("Copy"), false, () => Copy(flowchart)); + menu.AddItem(new GUIContent ("Cut"), false, () => Cut(flowchart)); + menu.AddItem(new GUIContent ("Duplicate"), false, DuplicateBlocks, blockList); + menu.AddItem(new GUIContent ("Delete"), false, DeleteBlocks, blockList); + } + // Clicked on empty space in grid + else + { + DeselectAll(flowchart); + + menu.AddItem(new GUIContent("Add Block"), false, () => CreateBlock(flowchart, mousePosition / flowchart.Zoom - flowchart.ScrollPos)); + + if (copyList.Count > 0) + { + menu.AddItem(new GUIContent("Paste"), false, () => Paste(flowchart, mousePosition)); + } + else + { + menu.AddDisabledItem(new GUIContent("Paste")); + } + } + + var menuRect = new Rect(); + menuRect.position = new Vector2(mousePosition.x, mousePosition.y - 12f); + menu.DropDown(menuRect); + Event.current.Use(); + } // If event has yet to be used and user isn't multiselecting or panning, clear selection bool validModifier = Event.current.alt || GetAppendModifierDown(); if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && !validModifier) { - Undo.RecordObject(flowchart, "Deselect"); - flowchart.ClearSelectedCommands(); - flowchart.ClearSelectedBlocks(); - Selection.activeGameObject = flowchart.gameObject; + DeselectAll(flowchart); } // Draw selection box @@ -474,12 +551,11 @@ namespace Fungus.EditorUtils } } - public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks) + public virtual Vector2 GetBlockCenter(Flowchart flowchart, Block[] blocks) { - if (flowchart == null || - blocks.Count() == 0) + if (blocks.Length == 0) { - return; + return Vector2.zero; } Vector2 min = blocks[0]._NodeRect.min; @@ -493,8 +569,12 @@ namespace Fungus.EditorUtils max.y = Mathf.Max(max.y, block._NodeRect.center.y); } - Vector2 center = (min + max) * -0.5f; + return (min + max) * 0.5f; + } + public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks) + { + var center = -GetBlockCenter(flowchart, blocks); center.x += position.width * 0.5f / flowchart.Zoom; center.y += position.height * 0.5f / flowchart.Zoom; @@ -559,7 +639,7 @@ namespace Fungus.EditorUtils if (Event.current.rawType == EventType.MouseUp) { selectionBox.size = Vector2.zero; - selectionBox.position = Vector2.one * -1; + selectionBox.position = -Vector2.one; startSelectionBoxPosition = selectionBox.position; var tempList = new List(flowchart.SelectedBlocks); @@ -688,6 +768,14 @@ namespace Fungus.EditorUtils flowchart.SelectedBlock = block; SetBlockForInspector(flowchart, block); } + + protected virtual void DeselectAll(Flowchart flowchart) + { + Undo.RecordObject(flowchart, "Deselect"); + flowchart.ClearSelectedCommands(); + flowchart.ClearSelectedBlocks(); + Selection.activeGameObject = flowchart.gameObject; + } public static Block CreateBlock(Flowchart flowchart, Vector2 position) { @@ -854,20 +942,6 @@ namespace Fungus.EditorUtils descriptionStyle.wordWrap = true; GUILayout.Label(block.Description, descriptionStyle); } - - if (Event.current.type == EventType.ContextClick) - { - flowchart.AddSelectedBlock(block); - - GenericMenu menu = new GenericMenu (); - - // Use a copy because flowchart.SelectedBlocks gets modified - var blockList = new List(flowchart.SelectedBlocks); - menu.AddItem(new GUIContent ("Duplicate"), false, DuplicateBlocks, blockList); - menu.AddItem(new GUIContent ("Delete"), false, DeleteBlocks, blockList); - - menu.ShowAsContext(); - } } protected virtual void DrawConnections(Flowchart flowchart, Block block, bool highlightedOnly) @@ -989,6 +1063,11 @@ namespace Fungus.EditorUtils } protected static void DuplicateBlocks(object obj) + { + DuplicateBlocks(obj, new Vector2(20, 0)); + } + + protected static void DuplicateBlocks(object obj, Vector2 offset) { var flowchart = GetFlowchart(); @@ -999,9 +1078,7 @@ namespace Fungus.EditorUtils foreach (var block in blocks) { - Vector2 newPosition = new Vector2(block._NodeRect.position.x + - block._NodeRect.width + 20, - block._NodeRect.y); + Vector2 newPosition = block._NodeRect.position + offset; Block oldBlock = block; @@ -1087,9 +1164,102 @@ namespace Fungus.EditorUtils } } - protected virtual bool GetAppendModifierDown() + protected virtual bool GetAppendModifierDown() { return Event.current.shift || EditorGUI.actionKey; } + + protected virtual void Copy(Flowchart flowchart) + { + copyList.Clear(); + flowchart.SelectedBlocks.ForEach(block => copyList.Add(block)); + } + + protected virtual void Cut(Flowchart flowchart) + { + Copy(flowchart); + Undo.RecordObject(flowchart, "Cut"); + DeleteBlocks(flowchart.SelectedBlocks); + } + + // Center is position in unscaled window space + protected virtual void Paste(Flowchart flowchart, Vector2 center) + { + var copiedCenter = GetBlockCenter(flowchart, copyList.ToArray()) + flowchart.ScrollPos; + var delta = (center / flowchart.Zoom - copiedCenter); + + Undo.RecordObject(flowchart, "Paste"); + DuplicateBlocks(copyList, delta); + } + + protected virtual void ValidateCommands(Flowchart flowchart) + { + if (Event.current.type == EventType.ValidateCommand) + { + var c = Event.current.commandName; + if (c == "Copy" || c == "Cut" || c == "Delete" || c == "Duplicate") + { + if (flowchart.SelectedBlocks.Count > 0) + { + Event.current.Use(); + } + } + else if (c == "Paste") + { + if (copyList.Count > 0) + { + Event.current.Use(); + } + } + else if (c == "SelectAll") + { + Event.current.Use(); + } + } + } + + protected virtual void ExecuteCommands(Flowchart flowchart) + { + if (Event.current.type == EventType.ExecuteCommand) + { + switch (Event.current.commandName) + { + case "Copy": + Copy(flowchart); + Event.current.Use(); + break; + + case "Cut": + Cut(flowchart); + Event.current.Use(); + break; + + case "Paste": + Paste(flowchart, position.center - position.position); + Event.current.Use(); + break; + + case "Delete": + DeleteBlocks(flowchart.SelectedBlocks); + Event.current.Use(); + break; + + case "Duplicate": + DuplicateBlocks(new List(flowchart.SelectedBlocks)); + Event.current.Use(); + break; + + case "SelectAll": + Undo.RecordObject(flowchart, "Selection"); + flowchart.ClearSelectedBlocks(); + foreach (var block in flowchart.GetComponents()) + { + flowchart.AddSelectedBlock(block); + } + Event.current.Use(); + break; + } + } + } } } \ No newline at end of file From 92b3c810204359521eca24070f213aefbe9be6d5 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Sun, 6 Nov 2016 23:20:50 -0800 Subject: [PATCH 02/22] Added pro skin icons and moved editor textures - Added Fungus Editor Resources folder for editor textures (these should no longer get included in builds) - Added pro skin icons in Fungus Editor Resources/Icons/Pro - All editor textures should now be accessible as properties in FungusEditorResources. If the textures change, use Tools -> Fungus -> Utilities -> UpdateEditorResourcesScript to automatically update this --- Assets/Fungus/Fungus Editor Resources.meta | 9 + .../Icons.meta | 0 .../Fungus Editor Resources/Icons/Pro.meta | 9 + .../Fungus Editor Resources/Icons/Pro/add.png | Bin 0 -> 865 bytes .../Icons/Pro/add.png.meta} | 16 +- .../Icons/Pro/add_small.png | Bin 0 -> 865 bytes .../Icons/Pro/add_small.png.meta} | 16 +- .../Icons/Pro/delete.png | Bin 0 -> 1076 bytes .../Icons/Pro/delete.png.meta} | 16 +- .../Icons/Pro/down.png | Bin 0 -> 1069 bytes .../Icons/Pro/down.png.meta | 59 ++++++ .../Icons/Pro/duplicate.png | Bin 0 -> 1106 bytes .../Icons/Pro/duplicate.png.meta | 59 ++++++ .../Fungus Editor Resources/Icons/Pro/up.png | Bin 0 -> 1025 bytes .../Icons/Pro/up.png.meta | 59 ++++++ .../Icons/add.png | Bin .../Icons/add.png.meta | 0 .../Icons/add_small.png | Bin .../Icons/add_small.png.meta | 0 .../Icons/delete.png | Bin .../Icons/delete.png.meta | 0 .../Icons/down.png | Bin .../Icons/down.png.meta | 0 .../Icons/duplicate.png | Bin .../Icons/duplicate.png.meta | 0 .../Icons/up.png | Bin .../Icons/up.png.meta | 0 .../Textures.meta | 0 .../Textures/choice_node_off.png | Bin .../Textures/choice_node_off.png.meta | 0 .../Textures/choice_node_on.png | Bin .../Textures/choice_node_on.png.meta | 0 .../Textures/command_background.png | Bin .../Textures/command_background.png.meta | 0 .../Textures/event_node_off.png | Bin .../Textures/event_node_off.png.meta | 0 .../Textures/event_node_on.png | Bin .../Textures/event_node_on.png.meta | 0 .../Textures/play_big.png | Bin .../Textures/play_big.png.meta | 0 .../Textures/play_small.png | Bin .../Textures/play_small.png.meta | 0 .../Textures/process_node_off.png | Bin .../Textures/process_node_off.png.meta | 0 .../Textures/process_node_on.png | Bin .../Textures/process_node_on.png.meta | 0 .../Fungus/Resources/Icons/ResizeHandle.png | Bin 2968 -> 0 bytes Assets/Fungus/Resources/Icons/left.png | Bin 2911 -> 0 bytes Assets/Fungus/Resources/Icons/right.png | Bin 2903 -> 0 bytes Assets/Fungus/Scripts/Editor/BlockEditor.cs | 10 +- .../Scripts/Editor/CommandListAdaptor.cs | 4 +- .../Fungus/Scripts/Editor/FlowchartEditor.cs | 2 +- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 16 +- .../Scripts/Editor/FungusEditorResources.cs | 199 ++++++------------ .../Editor/FungusEditorResourcesGenerated.cs | 26 +++ .../FungusEditorResourcesGenerated.cs.meta | 12 ++ 56 files changed, 345 insertions(+), 167 deletions(-) create mode 100644 Assets/Fungus/Fungus Editor Resources.meta rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons.meta (100%) create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro.meta create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png rename Assets/Fungus/{Resources/Icons/right.png.meta => Fungus Editor Resources/Icons/Pro/add.png.meta} (77%) create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/add_small.png rename Assets/Fungus/{Resources/Icons/ResizeHandle.png.meta => Fungus Editor Resources/Icons/Pro/add_small.png.meta} (77%) create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png rename Assets/Fungus/{Resources/Icons/left.png.meta => Fungus Editor Resources/Icons/Pro/delete.png.meta} (77%) create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png.meta create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png.meta create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png create mode 100644 Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png.meta rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/add.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/add.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/add_small.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/add_small.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/delete.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/delete.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/down.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/down.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/duplicate.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/duplicate.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/up.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Icons/up.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/choice_node_off.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/choice_node_off.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/choice_node_on.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/choice_node_on.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/command_background.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/command_background.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/event_node_off.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/event_node_off.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/event_node_on.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/event_node_on.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/play_big.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/play_big.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/play_small.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/play_small.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/process_node_off.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/process_node_off.png.meta (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/process_node_on.png (100%) rename Assets/Fungus/{Resources => Fungus Editor Resources}/Textures/process_node_on.png.meta (100%) delete mode 100644 Assets/Fungus/Resources/Icons/ResizeHandle.png delete mode 100644 Assets/Fungus/Resources/Icons/left.png delete mode 100644 Assets/Fungus/Resources/Icons/right.png create mode 100644 Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs create mode 100644 Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs.meta diff --git a/Assets/Fungus/Fungus Editor Resources.meta b/Assets/Fungus/Fungus Editor Resources.meta new file mode 100644 index 00000000..81e8ab72 --- /dev/null +++ b/Assets/Fungus/Fungus Editor Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5ff164265158945c18b7d438b570ba22 +folderAsset: yes +timeCreated: 1478502248 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Resources/Icons.meta b/Assets/Fungus/Fungus Editor Resources/Icons.meta similarity index 100% rename from Assets/Fungus/Resources/Icons.meta rename to Assets/Fungus/Fungus Editor Resources/Icons.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro.meta b/Assets/Fungus/Fungus Editor Resources/Icons/Pro.meta new file mode 100644 index 00000000..9dab8a98 --- /dev/null +++ b/Assets/Fungus/Fungus Editor Resources/Icons/Pro.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5e5a1319ef7f546a7affe3baabd5fba6 +folderAsset: yes +timeCreated: 1478502692 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png new file mode 100644 index 0000000000000000000000000000000000000000..23646d93077e6966bca77415871932dbb13c9752 GIT binary patch literal 865 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqBDG7;Q2`B1$5BeXNr6bM+Ea@{>~a zDsl^e@(c_%_7w$*$=RtT3Q4KynR&KK?|1K4QpilPRSGxtHSjHPPR+>ls47YguJQ{> zuF6ifOi{A8KQ26aVgjorKDK}xwt_!19`Se86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZ zx=P7{9OiaozEwNS74=qkDD%P(`OwP~; zD#PfSVCE67V%(g(RhALa+U*xFl2C2Z)X@p*X#LS6v?aLt zhXP9{*S=X#CV98m^zCL5^ya=TB4)S2u%mZt*&}-ej;5&21Z^=cGo|M_LLLIfr{C56 zzCH8i-N=G9DqE*qHDFm;a*gM#Pi0uxbsJxOi_9f+_1F&2O7+pxVOfzG&wpj*&wcSv zSH1nd-g2>_ck`~ahn!~(HXqu2=-}El3x7D=SgU#{@FDj@yI?(yKTE!Nblw*^-u))P z^6s;s6Z&t&z8zU@5p*=_kPl}+SNZZumTPO|zfQUqQB@iE^3v`N9EOKQ*B=V`a#vp{WY>MYbl24Hnl^_n@v-DR{J>Flu6&2D z%K%d^XMsm#F#`j)FbFd;%$g$s6twbmaSXBOO-_(tUEI(J1P@P4RQ}&DWBF;m#8#gx z+vdDtGkP>h;fbrXwDg*)mG7Ju9r(~SCD1^Kfgztu&_d{2*)>qk@O1TaS?83{1OQNW BPon?; literal 0 HcmV?d00001 diff --git a/Assets/Fungus/Resources/Icons/right.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png.meta similarity index 77% rename from Assets/Fungus/Resources/Icons/right.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png.meta index 7c6971a5..422af796 100644 --- a/Assets/Fungus/Resources/Icons/right.png.meta +++ b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png.meta @@ -1,5 +1,7 @@ fileFormatVersion: 2 -guid: b3dd8b25a62664f379cb3714060d4e33 +guid: 4e43c476b4a7a49a08c37378fb01ce99 +timeCreated: 1478502692 +licenseType: Free TextureImporter: fileIDToRecycleName: {} serializedVersion: 2 @@ -15,17 +17,17 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 generateCubemap: 0 cubemapConvolution: 0 - cubemapConvolutionSteps: 8 + cubemapConvolutionSteps: 7 cubemapConvolutionExponent: 1.5 seamlessCubemap: 0 textureFormat: -3 - maxTextureSize: 1024 + maxTextureSize: 2048 textureSettings: filterMode: -1 aniso: 1 @@ -35,18 +37,22 @@ TextureImporter: lightmap: 0 rGBM: 0 compressionQuality: 50 + allowsAlphaSplitting: 0 spriteMode: 0 spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 0, y: 0, z: 0, w: 0} spritePixelsToUnits: 100 alphaIsTransparency: 1 + spriteTessellationDetail: -1 textureType: 2 buildTargetSettings: [] spriteSheet: + serializedVersion: 2 sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add_small.png b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add_small.png new file mode 100644 index 0000000000000000000000000000000000000000..cf6b201ee000847da384d4353aed81a6769252f9 GIT binary patch literal 865 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKV06k1i71Ki^|4CM&(%vz$xlkv ztH>-n*TA>HIW;5GqpB!1xXLdi zxhgx^GDXSWj?1RP3TQxXYDuC(MQ%=Bu~mhw64+cTAR8pCucQE0Qj%?}6yY17;GAES zs$i;Ts%M~N$E9FXl#*r@k>g7FXt#Bv$C=6)S^`fSBQuTAW;zSx}OhpQivaGchT@w8U0PKeRZts93)$F*!pY zs3f~2zd+wJIX|yhKQSdGzBo5ACr7U!FI`C=?qJ~zj%>^YLljpPEbed zj~<~d!OcGuSUS1(&3ZD)yTzt&H;bS*_iYg|yA6gNy<5v3*(-1~MRg`!@{oH`086^E}5&xc6e5*kDd<8ip+Ta zD=UBQi+{T6?f3PTiw(V-ccne#JZrG|(B?x2*REOk!{NqS)kA>~xgXjE>uLO1^2MX` zzR2TONfl8g)b%QzUBP>ePvrcSAc%$&YSCxq<>3%6Z@sc^|c-2b-kFl z@GU1KW1cSje3N7L!$l$bcNf0?P{^0N`a&VQ?(3zyrheD7IdqASCGX(}j;bT~w|?Z7 z<4t$vJA7RRn1(qEJR*x37`TN&n2}-D90{PHiKmNWh(&L5f&^>D!6sJjfBF#{9@yKN z`b>#(+Q``Rf~jTBoCy;e7PTjdKVWrM7I0@|W@g~q!QbH)HTNVaXL!2$xvX~a zDsl^e@(c_%_7w$*$=RtT3Q4KynR&KK?|1K4QpilPRSGxtHSjHPPR+>ls47YguJQ{> zuF6ifOi{A8KQ26aVgjorKDK}xwt_!19`Se86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZ zx=P7{9OiaozEwNS74=qkDD%P(`OwP~; zD#Pf5*5ElJfY$V*q!2RTF^>Jp%r^x=L2a^RtongnD>p{1Fbu92Q01B1rI(uuphnH>e%?H4bSP;JuG(Fy8k{m~<| zCAj&A0!t^?zFAKudAHc~?Pd}5=DsZ=X1BqxqjziBBYOporl`&YZ80u0rRO<99s$bvO0Tc=z#U|CsmjpwXSWmwpC8()2k%q4U6*bdK1_0iK|S&mJ&t9mH#A@@VOU_FgLOTKt?-WNIE z{U*Tj?z5m1`ftR(9a(J=bTsOa4`)AD`SMAYYis1cPP!IRRT=p5((Vl$hKEJup3OMc z-=BCa^~=Tn>5P$q%J-ss_$N(_@O5j>^)c(5tl&L=h2=@P$&uo=YPyB`!}F#}JF&x04q70i&et|IA2NfsR$dN2hh! z9f*C$D)o!aLgb~kLIu0X`GDZw9Vh3l(Oor3K&9zHp4dUzojMz06jVh2y!-!czP<5D zrr&yAwqc>APv+caIuZ5dg2`FW$Z7t~T(5WSV=1`k+|IzaXr?&BdE5HA&wqxd$Jk3c z-4MK(oAo+Eu_e}M!7Aa3Fu%H|j3$i8nLj7*j907sy`- Qxd6)Sp00i_>zopr06;>sEC2ui literal 0 HcmV?d00001 diff --git a/Assets/Fungus/Resources/Icons/left.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png.meta similarity index 77% rename from Assets/Fungus/Resources/Icons/left.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png.meta index 546dd74e..da792108 100644 --- a/Assets/Fungus/Resources/Icons/left.png.meta +++ b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png.meta @@ -1,5 +1,7 @@ fileFormatVersion: 2 -guid: c0a7a4711d69249ab9dae1539a3247ee +guid: 29c4d29b1678042a5b3516c732ccc507 +timeCreated: 1478502692 +licenseType: Free TextureImporter: fileIDToRecycleName: {} serializedVersion: 2 @@ -15,17 +17,17 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 generateCubemap: 0 cubemapConvolution: 0 - cubemapConvolutionSteps: 8 + cubemapConvolutionSteps: 7 cubemapConvolutionExponent: 1.5 seamlessCubemap: 0 textureFormat: -3 - maxTextureSize: 1024 + maxTextureSize: 2048 textureSettings: filterMode: -1 aniso: 1 @@ -35,18 +37,22 @@ TextureImporter: lightmap: 0 rGBM: 0 compressionQuality: 50 + allowsAlphaSplitting: 0 spriteMode: 0 spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 0, y: 0, z: 0, w: 0} spritePixelsToUnits: 100 alphaIsTransparency: 1 + spriteTessellationDetail: -1 textureType: 2 buildTargetSettings: [] spriteSheet: + serializedVersion: 2 sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png new file mode 100644 index 0000000000000000000000000000000000000000..b84dbd531df99f234508b6cdf6836c40959fa038 GIT binary patch literal 1069 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqBDG7;Q5{B1$5BeXNr6bM+Ea@{>~a zDsl^e@(c_%_7w$*$=RtT3Q4KynR&KK?|1K4QpilPRSGxtHSjHPPR+>ls47YguJQ{> zuF6ifOi{A8KQ26aVgjorKDK}xwt_!19`Se86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZ zx=P7{9OiaozEwNS74=qkDD%P(`OwP~; zD#PsuOO(<{hJSJDSLLm%o6pojF~J_2&!VUn5$42UA2k9Dnmo&p21 zHPhKSpg73gNx{?A+04+=%uLrv&yayZV`AyV-QLWO0`2yT7fGl#Y3k?%b+rEI5!w>m z{6m4IlWX6sCzHHeZ2ESy2zqnh77?@CVA#>Swd|3-0!LF+XM(mEmzmP@93c+@9DNGjOV|y^5?$z zr>ow6UvIhC(7Sn8+C$E>2AdCUK6G&HnuR|cZmd;36!?()pRs$e0gd21`fl+B681W9P95- zJeK<9V*hl;$Uxw$*b5=$G!ix&BD{x5PKGUus-m+c93(i-`;0azZlZ z>B7%9Ic7gx6rz83;p-2De7UPH6te5SUb<`QcTJl^m-txn9)94cI&y#OM{YUZbXUH^ z*JXgom$SelvY3H^TNs2H8D`Cq0LBulr;B5VMeozewtmcp0b5Cf~GVQvwbi<8f#Z%`bwHldtZ&CUk?BKfWQ_u6-s%i5YH*53hu6Sj7 zGMvF+v$SC3*SEX(7nL155V%?MbkUU5o6-&Cf;Yc%hL-X?*tBZZYMb-+{xZiT=6Ufv#$4&-@?uI z<%pZhv$SnFjk>!N_VP*l$$Q*0P5ACS>tN8;)>V3SyuapuWp!=MQE~Z^QwqxEp00i_ I>zopr06uWF@c;k- literal 0 HcmV?d00001 diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png.meta new file mode 100644 index 00000000..9dba1d7d --- /dev/null +++ b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png.meta @@ -0,0 +1,59 @@ +fileFormatVersion: 2 +guid: 5a87a7d3683164a238377d948572805f +timeCreated: 1478502692 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png new file mode 100644 index 0000000000000000000000000000000000000000..7a36f572a8b6eff2d19ba3f0a606ddcaf93a82f8 GIT binary patch literal 1106 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqBDG7@aahB1$5BeXNr6bM+Ea@{>~a zDsl^e@(c_%_7w$*$=RtT3Q4KynR&KK?|1K4QpilPRSGxtHSjHPPR+>ls47YguJQ{> zuF6ifOi{A8KQ26aVgjorKDK}xwt_!19`Se86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZ zx=P7{9OiaozEwNS74=qkDD%P(`OwP~; zD#Pbn?P$xKcxN!2UJOIOkdxkVr97@)88;obsr-~p4G2MmoOpts|$ z^DYI3W^1Oib3k#ByOV;atFxJ*rJ0$ok)9y~gT}J5 z(Id1axcP?yODEU9Sx+W;x7hUUW)bw}zAYkVx52QZcWc=rdj*cBsLlj!F)lNu=Q%-D`)&0Ib^XA>if;B2zr(88)Sy^(8=d4da*$x|(uHulWC6 zyLQQa&r;#2=Lodhp)>3(=ca&M`SSr1Gg{;GcwGYBLR#hRZkbk5R2ZclMMZi7znujSJ*NsFk;)1 zCC?ZpM%*m%Y_?!H{(vE*dWLBD2JSFx<%@;98W|26FC}KFcrEIcwfZsjuWjAGZR|f@ zFDg?|`Zc>ZG<5FN)Ss5$`rSW^GyG=B=2e&~a zDsl^e@(c_%_7w$*$=RtT3Q4KynR&KK?|1K4QpilPRSGxtHSjHPPR+>ls47YguJQ{> zuF6ifOi{A8KQ26aVgjorKDK}xwt_!19`Se86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZ zx=P7{9OiaozEwNS74=qkDD%P(`OwP~; zD#FD=k3$V*q!2RT9?>I$HD^x^&ia^NA7ngAH7>uo% z&dveFLGDfpp03VjhL&b#x<-123=A3*ODFF3W_A>4w_m(SLbXX#M<=MG^+%7;mf+?e z3M`#m`({0v>)6)kjZDJ+|Gu)Vo-07Vbmz_WN7BC~zKQ)(d+F0uaHS3#!}noCzMXlgnq_vf%n+{d`(LTT3G&`r}o OIoH$G&t;ucLK6U96rpnf literal 0 HcmV?d00001 diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png.meta new file mode 100644 index 00000000..2371a0d0 --- /dev/null +++ b/Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png.meta @@ -0,0 +1,59 @@ +fileFormatVersion: 2 +guid: 2a76a781db2994b33b83cd84b8835da7 +timeCreated: 1478502692 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Resources/Icons/add.png b/Assets/Fungus/Fungus Editor Resources/Icons/add.png similarity index 100% rename from Assets/Fungus/Resources/Icons/add.png rename to Assets/Fungus/Fungus Editor Resources/Icons/add.png diff --git a/Assets/Fungus/Resources/Icons/add.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/add.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/add.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/add.png.meta diff --git a/Assets/Fungus/Resources/Icons/add_small.png b/Assets/Fungus/Fungus Editor Resources/Icons/add_small.png similarity index 100% rename from Assets/Fungus/Resources/Icons/add_small.png rename to Assets/Fungus/Fungus Editor Resources/Icons/add_small.png diff --git a/Assets/Fungus/Resources/Icons/add_small.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/add_small.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/add_small.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/add_small.png.meta diff --git a/Assets/Fungus/Resources/Icons/delete.png b/Assets/Fungus/Fungus Editor Resources/Icons/delete.png similarity index 100% rename from Assets/Fungus/Resources/Icons/delete.png rename to Assets/Fungus/Fungus Editor Resources/Icons/delete.png diff --git a/Assets/Fungus/Resources/Icons/delete.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/delete.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/delete.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/delete.png.meta diff --git a/Assets/Fungus/Resources/Icons/down.png b/Assets/Fungus/Fungus Editor Resources/Icons/down.png similarity index 100% rename from Assets/Fungus/Resources/Icons/down.png rename to Assets/Fungus/Fungus Editor Resources/Icons/down.png diff --git a/Assets/Fungus/Resources/Icons/down.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/down.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/down.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/down.png.meta diff --git a/Assets/Fungus/Resources/Icons/duplicate.png b/Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png similarity index 100% rename from Assets/Fungus/Resources/Icons/duplicate.png rename to Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png diff --git a/Assets/Fungus/Resources/Icons/duplicate.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/duplicate.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png.meta diff --git a/Assets/Fungus/Resources/Icons/up.png b/Assets/Fungus/Fungus Editor Resources/Icons/up.png similarity index 100% rename from Assets/Fungus/Resources/Icons/up.png rename to Assets/Fungus/Fungus Editor Resources/Icons/up.png diff --git a/Assets/Fungus/Resources/Icons/up.png.meta b/Assets/Fungus/Fungus Editor Resources/Icons/up.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/up.png.meta rename to Assets/Fungus/Fungus Editor Resources/Icons/up.png.meta diff --git a/Assets/Fungus/Resources/Textures.meta b/Assets/Fungus/Fungus Editor Resources/Textures.meta similarity index 100% rename from Assets/Fungus/Resources/Textures.meta rename to Assets/Fungus/Fungus Editor Resources/Textures.meta diff --git a/Assets/Fungus/Resources/Textures/choice_node_off.png b/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_off.png rename to Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png diff --git a/Assets/Fungus/Resources/Textures/choice_node_off.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_off.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png.meta diff --git a/Assets/Fungus/Resources/Textures/choice_node_on.png b/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_on.png rename to Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png diff --git a/Assets/Fungus/Resources/Textures/choice_node_on.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_on.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png.meta diff --git a/Assets/Fungus/Resources/Textures/command_background.png b/Assets/Fungus/Fungus Editor Resources/Textures/command_background.png similarity index 100% rename from Assets/Fungus/Resources/Textures/command_background.png rename to Assets/Fungus/Fungus Editor Resources/Textures/command_background.png diff --git a/Assets/Fungus/Resources/Textures/command_background.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/command_background.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/command_background.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/command_background.png.meta diff --git a/Assets/Fungus/Resources/Textures/event_node_off.png b/Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_off.png rename to Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png diff --git a/Assets/Fungus/Resources/Textures/event_node_off.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_off.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png.meta diff --git a/Assets/Fungus/Resources/Textures/event_node_on.png b/Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_on.png rename to Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png diff --git a/Assets/Fungus/Resources/Textures/event_node_on.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_on.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png.meta diff --git a/Assets/Fungus/Resources/Textures/play_big.png b/Assets/Fungus/Fungus Editor Resources/Textures/play_big.png similarity index 100% rename from Assets/Fungus/Resources/Textures/play_big.png rename to Assets/Fungus/Fungus Editor Resources/Textures/play_big.png diff --git a/Assets/Fungus/Resources/Textures/play_big.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/play_big.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/play_big.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/play_big.png.meta diff --git a/Assets/Fungus/Resources/Textures/play_small.png b/Assets/Fungus/Fungus Editor Resources/Textures/play_small.png similarity index 100% rename from Assets/Fungus/Resources/Textures/play_small.png rename to Assets/Fungus/Fungus Editor Resources/Textures/play_small.png diff --git a/Assets/Fungus/Resources/Textures/play_small.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/play_small.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/play_small.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/play_small.png.meta diff --git a/Assets/Fungus/Resources/Textures/process_node_off.png b/Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_off.png rename to Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png diff --git a/Assets/Fungus/Resources/Textures/process_node_off.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_off.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png.meta diff --git a/Assets/Fungus/Resources/Textures/process_node_on.png b/Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_on.png rename to Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png diff --git a/Assets/Fungus/Resources/Textures/process_node_on.png.meta b/Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_on.png.meta rename to Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png.meta diff --git a/Assets/Fungus/Resources/Icons/ResizeHandle.png b/Assets/Fungus/Resources/Icons/ResizeHandle.png deleted file mode 100644 index aedc1d2e9485e837bceb1d9c77a7de6639608747..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2968 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 1) { - offTex = FungusEditorResources.texChoiceNodeOff; - onTex = FungusEditorResources.texChoiceNodeOn; + offTex = FungusEditorResources.ChoiceNodeOff; + onTex = FungusEditorResources.ChoiceNodeOn; defaultColor = FungusConstants.DefaultChoiceBlockTint; } else { - offTex = FungusEditorResources.texProcessNodeOff; - onTex = FungusEditorResources.texProcessNodeOn; + offTex = FungusEditorResources.ProcessNodeOff; + onTex = FungusEditorResources.ProcessNodeOn; defaultColor = FungusConstants.DefaultProcessBlockTint; } } diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index 9c35cc05..dad69a76 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -1,149 +1,76 @@ // This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). // It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) -using UnityEngine; +using UnityEngine; using UnityEditor; +using System.IO; using System; +using System.Linq; +using System.Collections.Generic; -namespace Fungus.EditorUtils +namespace Fungus.EditorUtils { - internal static class FungusEditorResources - { + internal static partial class FungusEditorResources + { + private static Dictionary textures = new Dictionary(); + + static FungusEditorResources() + { + LoadResourceAssets(); + } - static FungusEditorResources() { - GenerateSpecialTextures(); - LoadResourceAssets(); - } + private static void LoadResourceAssets() + { + // Get first folder named "Fungus Editor Resources" + var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0]; + var root = AssetDatabase.GUIDToAssetPath(rootGuid); + var guids = AssetDatabase.FindAssets("t:Texture2D", new string[] { root }); + var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/")); - private enum ResourceName - { - command_background = 0, - choice_node_off, - choice_node_on, - process_node_off, - process_node_on, - event_node_off, - event_node_on, - play_big, - play_small - } - - private static string[] s_LightSkin = { - "command_background", - "choice_node_off", - "choice_node_on", - "process_node_off", - "process_node_on", - "event_node_off", - "event_node_on", - "play_big", - "play_small" - }; + foreach (var path in paths) + { + if (path.ToLower().Contains("/pro/") && !EditorGUIUtility.isProSkin) + { + return; + } + var texture = AssetDatabase.LoadAssetAtPath(path); + textures[texture.name] = texture; + } + } - private static string[] s_DarkSkin = { - "command_background", - "choice_node_off", - "choice_node_on", - "process_node_off", - "process_node_on", - "event_node_off", - "event_node_on", - "play_big", - "play_small" - }; + [MenuItem("Tools/Fungus/Utilities/Update Editor Resources Script")] + private static void GenerateResourcesScript() + { + var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0]; + var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs"); + var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length);// + + using (var writer = new StreamWriter(absolutePath)) + { + writer.WriteLine("// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus)."); + writer.WriteLine("// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)"); + writer.WriteLine(""); + writer.WriteLine("using UnityEngine;"); + writer.WriteLine(""); + writer.WriteLine("namespace Fungus.EditorUtils"); + writer.WriteLine("{"); + writer.WriteLine("\tinternal static partial class FungusEditorResources"); + writer.WriteLine("\t{"); - public static Texture2D texCommandBackground - { - get { return s_Cached[(int)ResourceName.command_background]; } - } + foreach (var pair in textures) + { + var name = pair.Key; + var pascalCase = string.Join("", name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select( + s => s.Substring(0, 1).ToUpper() + s.Substring(1)).ToArray() + ); + writer.WriteLine("\t\tpublic static Texture2D " + pascalCase + " { get { return textures[\"" + name + "\"]; } }"); + } - public static Texture2D texEventNodeOn - { - get { return s_Cached[(int)ResourceName.event_node_on]; } - } - - public static Texture2D texEventNodeOff - { - get { return s_Cached[(int)ResourceName.event_node_off]; } - } + writer.WriteLine("\t}"); + writer.WriteLine("}"); + } - public static Texture2D texProcessNodeOn - { - get { return s_Cached[(int)ResourceName.process_node_on]; } - } - - public static Texture2D texProcessNodeOff - { - get { return s_Cached[(int)ResourceName.process_node_off]; } - } - - public static Texture2D texChoiceNodeOn - { - get { return s_Cached[(int)ResourceName.choice_node_on]; } - } - - public static Texture2D texChoiceNodeOff - { - get { return s_Cached[(int)ResourceName.choice_node_off]; } - } - - public static Texture2D texPlayBig - { - get { return s_Cached[(int)ResourceName.play_big]; } - } - - public static Texture2D texPlaySmall - { - get { return s_Cached[(int)ResourceName.play_small]; } - } - - public static Texture2D texItemSplitter { get; private set; } - - private static void GenerateSpecialTextures() - { - var splitterColor = EditorGUIUtility.isProSkin - ? new Color(1f, 1f, 1f, 0.14f) - : new Color(0.59f, 0.59f, 0.59f, 0.55f) - ; - texItemSplitter = CreatePixelTexture("(Generated) Item Splitter", splitterColor); - } - - public static Texture2D CreatePixelTexture(string name, Color color) - { - var tex = new Texture2D(1, 1, TextureFormat.ARGB32, false, true); - tex.name = name; - tex.hideFlags = HideFlags.HideAndDontSave; - tex.filterMode = FilterMode.Point; - tex.SetPixel(0, 0, color); - tex.Apply(); - return tex; - } - - private static Texture2D[] s_Cached; - - public static void LoadResourceAssets() - { - var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin; - s_Cached = new Texture2D[skin.Length]; - - for (int i = 0; i < s_Cached.Length; ++i) - { - s_Cached[i] = Resources.Load("Textures/" + skin[i]) as Texture2D; - } - - s_LightSkin = null; - s_DarkSkin = null; - } - - private static void GetImageSize(byte[] imageData, out int width, out int height) - { - width = ReadInt(imageData, 3 + 15); - height = ReadInt(imageData, 3 + 15 + 2 + 2); - } - - private static int ReadInt(byte[] imageData, int offset) - { - return (imageData[offset] << 8) | imageData[offset + 1]; - } - } -} \ No newline at end of file + AssetDatabase.ImportAsset(relativePath); + } + } +} diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs new file mode 100644 index 00000000..d8f36b8b --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -0,0 +1,26 @@ +// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). +// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) + +using UnityEngine; + +namespace Fungus.EditorUtils +{ + internal static partial class FungusEditorResources + { + public static Texture2D Add { get { return textures["add"]; } } + public static Texture2D AddSmall { get { return textures["add_small"]; } } + public static Texture2D Delete { get { return textures["delete"]; } } + public static Texture2D Down { get { return textures["down"]; } } + public static Texture2D Duplicate { get { return textures["duplicate"]; } } + public static Texture2D Up { get { return textures["up"]; } } + public static Texture2D ChoiceNodeOff { get { return textures["choice_node_off"]; } } + public static Texture2D ChoiceNodeOn { get { return textures["choice_node_on"]; } } + public static Texture2D CommandBackground { get { return textures["command_background"]; } } + public static Texture2D EventNodeOff { get { return textures["event_node_off"]; } } + public static Texture2D EventNodeOn { get { return textures["event_node_on"]; } } + public static Texture2D PlayBig { get { return textures["play_big"]; } } + public static Texture2D PlaySmall { get { return textures["play_small"]; } } + public static Texture2D ProcessNodeOff { get { return textures["process_node_off"]; } } + public static Texture2D ProcessNodeOn { get { return textures["process_node_on"]; } } + } +} diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs.meta b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs.meta new file mode 100644 index 00000000..6d6fd014 --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f5119f9bdde234916bed657bdc751f76 +timeCreated: 1478502142 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 5af37c941544b842dc1d2541c6f2ef449d83ff7f Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Mon, 7 Nov 2016 07:19:06 -0800 Subject: [PATCH 03/22] Added check for zoom change to avoid constant repaint -forceRepaintCount no longer gets set every time OnGUI is called because of DoZoom function --- Assets/Fungus/Scripts/Editor/FlowchartWindow.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index b943fe9e..be03da99 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -210,7 +210,10 @@ namespace Fungus.EditorUtils ); GUILayout.Label(flowchart.Zoom.ToString("0.0#x"), EditorStyles.miniLabel, GUILayout.Width(30)); - DoZoom(flowchart, newZoom - flowchart.Zoom, Vector2.one * 0.5f); + if (newZoom != flowchart.Zoom) + { + DoZoom(flowchart, newZoom - flowchart.Zoom, Vector2.one * 0.5f); + } if (GUILayout.Button("Center", EditorStyles.toolbarButton)) { From 4fb4a2f07b5a0b09bb1a0d1556852b7735977147 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Mon, 7 Nov 2016 14:21:31 -0800 Subject: [PATCH 04/22] Removed copy/cut/paste functionality for now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Removed copy/cut/paste functionality so that those commands can be implemented in a future PR -Removed unreferenced “DeleteBlock” function --- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 74 +------------------ 1 file changed, 1 insertion(+), 73 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index be03da99..5de4942c 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -39,8 +39,6 @@ namespace Fungus.EditorUtils protected Vector2 startSelectionBoxPosition = -Vector2.one; protected List mouseDownSelectionState = new List(); - protected List copyList = new List(); - // Context Click occurs on MouseDown which interferes with panning // Track right click positions manually to show menus on MouseUp protected Vector2 rightClickDown = -Vector2.one; @@ -67,7 +65,6 @@ namespace Fungus.EditorUtils nodeStyle.wordWrap = true; addTexture = Resources.Load("Icons/add_small") as Texture2D; - copyList.Clear(); } protected virtual void OnInspectorUpdate() @@ -511,8 +508,6 @@ namespace Fungus.EditorUtils // Use a copy because flowchart.SelectedBlocks gets modified var blockList = new List(flowchart.SelectedBlocks); - menu.AddItem(new GUIContent ("Copy"), false, () => Copy(flowchart)); - menu.AddItem(new GUIContent ("Cut"), false, () => Cut(flowchart)); menu.AddItem(new GUIContent ("Duplicate"), false, DuplicateBlocks, blockList); menu.AddItem(new GUIContent ("Delete"), false, DeleteBlocks, blockList); } @@ -520,17 +515,7 @@ namespace Fungus.EditorUtils else { DeselectAll(flowchart); - menu.AddItem(new GUIContent("Add Block"), false, () => CreateBlock(flowchart, mousePosition / flowchart.Zoom - flowchart.ScrollPos)); - - if (copyList.Count > 0) - { - menu.AddItem(new GUIContent("Paste"), false, () => Paste(flowchart, mousePosition)); - } - else - { - menu.AddDisabledItem(new GUIContent("Paste")); - } } var menuRect = new Rect(); @@ -792,18 +777,6 @@ namespace Fungus.EditorUtils return newBlock; } - protected virtual void DeleteBlock(Flowchart flowchart, Block block) - { - var commandList = block.CommandList; - foreach (var command in commandList) - { - Undo.DestroyObjectImmediate(command); - } - - Undo.DestroyObjectImmediate((Block)block); - flowchart.ClearSelectedCommands(); - } - protected virtual void DrawWindow(int windowId) { var block = windowBlockMap[windowId]; @@ -1172,48 +1145,18 @@ namespace Fungus.EditorUtils return Event.current.shift || EditorGUI.actionKey; } - protected virtual void Copy(Flowchart flowchart) - { - copyList.Clear(); - flowchart.SelectedBlocks.ForEach(block => copyList.Add(block)); - } - - protected virtual void Cut(Flowchart flowchart) - { - Copy(flowchart); - Undo.RecordObject(flowchart, "Cut"); - DeleteBlocks(flowchart.SelectedBlocks); - } - - // Center is position in unscaled window space - protected virtual void Paste(Flowchart flowchart, Vector2 center) - { - var copiedCenter = GetBlockCenter(flowchart, copyList.ToArray()) + flowchart.ScrollPos; - var delta = (center / flowchart.Zoom - copiedCenter); - - Undo.RecordObject(flowchart, "Paste"); - DuplicateBlocks(copyList, delta); - } - protected virtual void ValidateCommands(Flowchart flowchart) { if (Event.current.type == EventType.ValidateCommand) { var c = Event.current.commandName; - if (c == "Copy" || c == "Cut" || c == "Delete" || c == "Duplicate") + if (c == "Delete" || c == "Duplicate") { if (flowchart.SelectedBlocks.Count > 0) { Event.current.Use(); } } - else if (c == "Paste") - { - if (copyList.Count > 0) - { - Event.current.Use(); - } - } else if (c == "SelectAll") { Event.current.Use(); @@ -1227,21 +1170,6 @@ namespace Fungus.EditorUtils { switch (Event.current.commandName) { - case "Copy": - Copy(flowchart); - Event.current.Use(); - break; - - case "Cut": - Cut(flowchart); - Event.current.Use(); - break; - - case "Paste": - Paste(flowchart, position.center - position.position); - Event.current.Use(); - break; - case "Delete": DeleteBlocks(flowchart.SelectedBlocks); Event.current.Use(); From 248096bbfe947c1f4962b5363b5982c1e3b48998 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Mon, 7 Nov 2016 15:06:05 -0800 Subject: [PATCH 05/22] Fixed compatibility with Unity 5.0 -Changed generic LoadAssetAtPath to non-generic version -Added GetTexture wrapper function to avoid key not found errors when moving things around --- .../Scripts/Editor/FungusEditorResources.cs | 21 +++++++++---- .../Editor/FungusEditorResourcesGenerated.cs | 30 +++++++++---------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index dad69a76..7e80874e 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -3,8 +3,8 @@ using UnityEngine; using UnityEditor; -using System.IO; using System; +using System.IO; using System.Linq; using System.Collections.Generic; @@ -24,7 +24,7 @@ namespace Fungus.EditorUtils // Get first folder named "Fungus Editor Resources" var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0]; var root = AssetDatabase.GUIDToAssetPath(rootGuid); - var guids = AssetDatabase.FindAssets("t:Texture2D", new string[] { root }); + var guids = AssetDatabase.FindAssets("t:Texture2D", new [] { root }); var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/")); foreach (var path in paths) @@ -33,7 +33,7 @@ namespace Fungus.EditorUtils { return; } - var texture = AssetDatabase.LoadAssetAtPath(path); + var texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D; textures[texture.name] = texture; } } @@ -43,7 +43,7 @@ namespace Fungus.EditorUtils { var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0]; var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs"); - var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length);// + var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length); using (var writer = new StreamWriter(absolutePath)) { @@ -63,7 +63,7 @@ namespace Fungus.EditorUtils var pascalCase = string.Join("", name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select( s => s.Substring(0, 1).ToUpper() + s.Substring(1)).ToArray() ); - writer.WriteLine("\t\tpublic static Texture2D " + pascalCase + " { get { return textures[\"" + name + "\"]; } }"); + writer.WriteLine("\t\tpublic static Texture2D " + pascalCase + " { get { return GetTexture(\"" + name + "\"); } }"); } writer.WriteLine("\t}"); @@ -72,5 +72,16 @@ namespace Fungus.EditorUtils AssetDatabase.ImportAsset(relativePath); } + + private static Texture2D GetTexture(string name) + { + Texture2D texture; + if (!textures.TryGetValue(name, out texture)) + { + Debug.LogWarning("Texture \"" + name + "\" not found!"); + } + + return texture; + } } } diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs index d8f36b8b..e79da844 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -7,20 +7,20 @@ namespace Fungus.EditorUtils { internal static partial class FungusEditorResources { - public static Texture2D Add { get { return textures["add"]; } } - public static Texture2D AddSmall { get { return textures["add_small"]; } } - public static Texture2D Delete { get { return textures["delete"]; } } - public static Texture2D Down { get { return textures["down"]; } } - public static Texture2D Duplicate { get { return textures["duplicate"]; } } - public static Texture2D Up { get { return textures["up"]; } } - public static Texture2D ChoiceNodeOff { get { return textures["choice_node_off"]; } } - public static Texture2D ChoiceNodeOn { get { return textures["choice_node_on"]; } } - public static Texture2D CommandBackground { get { return textures["command_background"]; } } - public static Texture2D EventNodeOff { get { return textures["event_node_off"]; } } - public static Texture2D EventNodeOn { get { return textures["event_node_on"]; } } - public static Texture2D PlayBig { get { return textures["play_big"]; } } - public static Texture2D PlaySmall { get { return textures["play_small"]; } } - public static Texture2D ProcessNodeOff { get { return textures["process_node_off"]; } } - public static Texture2D ProcessNodeOn { get { return textures["process_node_on"]; } } + public static Texture2D Add { get { return GetTexture("add"); } } + public static Texture2D AddSmall { get { return GetTexture("add_small"); } } + public static Texture2D Delete { get { return GetTexture("delete"); } } + public static Texture2D Down { get { return GetTexture("down"); } } + public static Texture2D Duplicate { get { return GetTexture("duplicate"); } } + public static Texture2D Up { get { return GetTexture("up"); } } + public static Texture2D ChoiceNodeOff { get { return GetTexture("choice_node_off"); } } + public static Texture2D ChoiceNodeOn { get { return GetTexture("choice_node_on"); } } + public static Texture2D CommandBackground { get { return GetTexture("command_background"); } } + public static Texture2D EventNodeOff { get { return GetTexture("event_node_off"); } } + public static Texture2D EventNodeOn { get { return GetTexture("event_node_on"); } } + public static Texture2D PlayBig { get { return GetTexture("play_big"); } } + public static Texture2D PlaySmall { get { return GetTexture("play_small"); } } + public static Texture2D ProcessNodeOff { get { return GetTexture("process_node_off"); } } + public static Texture2D ProcessNodeOn { get { return GetTexture("process_node_on"); } } } } From 60f9bc5fd2e57758c4dd44d5d2ce78aa875adfb2 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Tue, 8 Nov 2016 20:54:14 -0800 Subject: [PATCH 06/22] Added tolerance value for right click MouseUp context clicks --- Assets/Fungus/Scripts/Editor/FlowchartWindow.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index 5de4942c..9c49352f 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -42,6 +42,7 @@ namespace Fungus.EditorUtils // Context Click occurs on MouseDown which interferes with panning // Track right click positions manually to show menus on MouseUp protected Vector2 rightClickDown = -Vector2.one; + protected readonly float rightClickTolerance = 5f; [MenuItem("Tools/Fungus/Flowchart Window")] static void Init() @@ -310,7 +311,10 @@ namespace Fungus.EditorUtils } else if (Event.current.type == EventType.MouseDrag) { - rightClickDown = -Vector2.one; + if (Vector2.Distance(rightClickDown, Event.current.mousePosition) > rightClickTolerance) + { + rightClickDown = -Vector2.one; + } } } @@ -487,7 +491,7 @@ namespace Fungus.EditorUtils // Handle right click up outside of EditorZoomArea to avoid strange offsets if (Event.current.type == EventType.MouseUp && Event.current.button == 1 && - Event.current.mousePosition == rightClickDown && !mouseOverVariables) + rightClickDown != -Vector2.one && !mouseOverVariables) { var menu = new GenericMenu(); var mousePosition = rightClickDown; From 3d431cc591184700635991204468b00eedc9dd99 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Wed, 9 Nov 2016 23:24:53 -0800 Subject: [PATCH 07/22] Added generation of texture names to load directly -Added texture names array to generated script. These files all specifically loaded rather than looping through a particular folder. -Renamed some functions for better clarity --- .../Scripts/Editor/FungusEditorResources.cs | 37 ++++++++++++++++--- .../Editor/FungusEditorResourcesGenerated.cs | 18 +++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index 7e80874e..5ce80df0 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -16,17 +16,32 @@ namespace Fungus.EditorUtils static FungusEditorResources() { - LoadResourceAssets(); + LoadTexturesFromNames(); } - private static void LoadResourceAssets() + private static void LoadTexturesFromNames() + { + var baseDirectories = AssetDatabase.FindAssets("\"Fungus Editor Resources\"").Select( + guid => AssetDatabase.GUIDToAssetPath(guid) + ).ToArray(); + + foreach (var name in resourceNames) + { + LoadTexturesFromGUIDs(AssetDatabase.FindAssets(name + " t:Texture2D", baseDirectories)); + } + } + + private static void LoadAllTexturesInFolder() { - // Get first folder named "Fungus Editor Resources" var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0]; var root = AssetDatabase.GUIDToAssetPath(rootGuid); - var guids = AssetDatabase.FindAssets("t:Texture2D", new [] { root }); - var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/")); + LoadTexturesFromGUIDs(AssetDatabase.FindAssets("t:Texture2D", new [] { root })); + } + private static void LoadTexturesFromGUIDs(string[] guids) + { + var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/")); + foreach (var path in paths) { if (path.ToLower().Contains("/pro/") && !EditorGUIUtility.isProSkin) @@ -41,6 +56,9 @@ namespace Fungus.EditorUtils [MenuItem("Tools/Fungus/Utilities/Update Editor Resources Script")] private static void GenerateResourcesScript() { + textures.Clear(); + LoadAllTexturesInFolder(); + var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0]; var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs"); var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length); @@ -56,6 +74,15 @@ namespace Fungus.EditorUtils writer.WriteLine("{"); writer.WriteLine("\tinternal static partial class FungusEditorResources"); writer.WriteLine("\t{"); + writer.WriteLine("\t\tprivate static readonly string[] resourceNames = new [] {"); + + foreach (var pair in textures) + { + writer.WriteLine("\t\t\t\"" + pair.Key + "\","); + } + + writer.WriteLine("\t\t};"); + writer.WriteLine(""); foreach (var pair in textures) { diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs index e79da844..7dd62e34 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -7,6 +7,24 @@ namespace Fungus.EditorUtils { internal static partial class FungusEditorResources { + private static readonly string[] resourceNames = new [] { + "add", + "add_small", + "delete", + "down", + "duplicate", + "up", + "choice_node_off", + "choice_node_on", + "command_background", + "event_node_off", + "event_node_on", + "play_big", + "play_small", + "process_node_off", + "process_node_on", + }; + public static Texture2D Add { get { return GetTexture("add"); } } public static Texture2D AddSmall { get { return GetTexture("add_small"); } } public static Texture2D Delete { get { return GetTexture("delete"); } } From 5f677602c5540f84858b114b0cc034158d49453a Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Wed, 9 Nov 2016 23:46:10 -0800 Subject: [PATCH 08/22] Converted tabs to spaces in new files --- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 2 +- .../Scripts/Editor/FungusEditorResources.cs | 182 +++++++++--------- .../Editor/FungusEditorResourcesGenerated.cs | 70 +++---- 3 files changed, 127 insertions(+), 127 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index ed4e1463..c11ac1bd 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -473,7 +473,7 @@ namespace Fungus.EditorUtils GUI.color = new Color(1f, 1f, 1f, alpha); } - if (GUI.Button(rect, FungusEditorResources.PlayBig as Texture, new GUIStyle())) + if (GUI.Button(rect, FungusEditorResources.PlayBig, new GUIStyle())) { SelectBlock(flowchart, b); } diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index 5ce80df0..245de98a 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -10,105 +10,105 @@ using System.Collections.Generic; namespace Fungus.EditorUtils { - internal static partial class FungusEditorResources - { - private static Dictionary textures = new Dictionary(); - - static FungusEditorResources() - { - LoadTexturesFromNames(); - } + internal static partial class FungusEditorResources + { + private static Dictionary textures = new Dictionary(); + + static FungusEditorResources() + { + LoadTexturesFromNames(); + } - private static void LoadTexturesFromNames() - { - var baseDirectories = AssetDatabase.FindAssets("\"Fungus Editor Resources\"").Select( - guid => AssetDatabase.GUIDToAssetPath(guid) - ).ToArray(); - - foreach (var name in resourceNames) - { - LoadTexturesFromGUIDs(AssetDatabase.FindAssets(name + " t:Texture2D", baseDirectories)); - } - } + private static void LoadTexturesFromNames() + { + var baseDirectories = AssetDatabase.FindAssets("\"Fungus Editor Resources\"").Select( + guid => AssetDatabase.GUIDToAssetPath(guid) + ).ToArray(); + + foreach (var name in resourceNames) + { + LoadTexturesFromGUIDs(AssetDatabase.FindAssets(name + " t:Texture2D", baseDirectories)); + } + } - private static void LoadAllTexturesInFolder() - { - var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0]; - var root = AssetDatabase.GUIDToAssetPath(rootGuid); - LoadTexturesFromGUIDs(AssetDatabase.FindAssets("t:Texture2D", new [] { root })); - } + private static void LoadAllTexturesInFolder() + { + var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0]; + var root = AssetDatabase.GUIDToAssetPath(rootGuid); + LoadTexturesFromGUIDs(AssetDatabase.FindAssets("t:Texture2D", new [] { root })); + } - private static void LoadTexturesFromGUIDs(string[] guids) - { - var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/")); - - foreach (var path in paths) - { - if (path.ToLower().Contains("/pro/") && !EditorGUIUtility.isProSkin) - { - return; - } - var texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D; - textures[texture.name] = texture; - } - } + private static void LoadTexturesFromGUIDs(string[] guids) + { + var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/")); + + foreach (var path in paths) + { + if (path.ToLower().Contains("/pro/") && !EditorGUIUtility.isProSkin) + { + return; + } + var texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D; + textures[texture.name] = texture; + } + } - [MenuItem("Tools/Fungus/Utilities/Update Editor Resources Script")] - private static void GenerateResourcesScript() - { - textures.Clear(); - LoadAllTexturesInFolder(); + [MenuItem("Tools/Fungus/Utilities/Update Editor Resources Script")] + private static void GenerateResourcesScript() + { + textures.Clear(); + LoadAllTexturesInFolder(); - var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0]; - var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs"); - var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length); - - using (var writer = new StreamWriter(absolutePath)) - { - writer.WriteLine("// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus)."); - writer.WriteLine("// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)"); - writer.WriteLine(""); - writer.WriteLine("using UnityEngine;"); - writer.WriteLine(""); - writer.WriteLine("namespace Fungus.EditorUtils"); - writer.WriteLine("{"); - writer.WriteLine("\tinternal static partial class FungusEditorResources"); - writer.WriteLine("\t{"); - writer.WriteLine("\t\tprivate static readonly string[] resourceNames = new [] {"); - - foreach (var pair in textures) - { - writer.WriteLine("\t\t\t\"" + pair.Key + "\","); - } + var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0]; + var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs"); + var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length); + + using (var writer = new StreamWriter(absolutePath)) + { + writer.WriteLine("// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus)."); + writer.WriteLine("// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)"); + writer.WriteLine(""); + writer.WriteLine("using UnityEngine;"); + writer.WriteLine(""); + writer.WriteLine("namespace Fungus.EditorUtils"); + writer.WriteLine("{"); + writer.WriteLine(" internal static partial class FungusEditorResources"); + writer.WriteLine(" {"); + writer.WriteLine(" private static readonly string[] resourceNames = new [] {"); + + foreach (var pair in textures) + { + writer.WriteLine(" \"" + pair.Key + "\","); + } - writer.WriteLine("\t\t};"); - writer.WriteLine(""); + writer.WriteLine(" };"); + writer.WriteLine(""); - foreach (var pair in textures) - { - var name = pair.Key; - var pascalCase = string.Join("", name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select( - s => s.Substring(0, 1).ToUpper() + s.Substring(1)).ToArray() - ); - writer.WriteLine("\t\tpublic static Texture2D " + pascalCase + " { get { return GetTexture(\"" + name + "\"); } }"); - } + foreach (var pair in textures) + { + var name = pair.Key; + var pascalCase = string.Join("", name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select( + s => s.Substring(0, 1).ToUpper() + s.Substring(1)).ToArray() + ); + writer.WriteLine(" public static Texture2D " + pascalCase + " { get { return GetTexture(\"" + name + "\"); } }"); + } - writer.WriteLine("\t}"); - writer.WriteLine("}"); - } + writer.WriteLine(" }"); + writer.WriteLine("}"); + } - AssetDatabase.ImportAsset(relativePath); - } + AssetDatabase.ImportAsset(relativePath); + } - private static Texture2D GetTexture(string name) - { - Texture2D texture; - if (!textures.TryGetValue(name, out texture)) - { - Debug.LogWarning("Texture \"" + name + "\" not found!"); - } - - return texture; - } - } + private static Texture2D GetTexture(string name) + { + Texture2D texture; + if (!textures.TryGetValue(name, out texture)) + { + Debug.LogWarning("Texture \"" + name + "\" not found!"); + } + + return texture; + } + } } diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs index 7dd62e34..e2eab920 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -5,40 +5,40 @@ using UnityEngine; namespace Fungus.EditorUtils { - internal static partial class FungusEditorResources - { - private static readonly string[] resourceNames = new [] { - "add", - "add_small", - "delete", - "down", - "duplicate", - "up", - "choice_node_off", - "choice_node_on", - "command_background", - "event_node_off", - "event_node_on", - "play_big", - "play_small", - "process_node_off", - "process_node_on", - }; + internal static partial class FungusEditorResources + { + private static readonly string[] resourceNames = new [] { + "add", + "add_small", + "delete", + "down", + "duplicate", + "up", + "choice_node_off", + "choice_node_on", + "command_background", + "event_node_off", + "event_node_on", + "play_big", + "play_small", + "process_node_off", + "process_node_on", + }; - public static Texture2D Add { get { return GetTexture("add"); } } - public static Texture2D AddSmall { get { return GetTexture("add_small"); } } - public static Texture2D Delete { get { return GetTexture("delete"); } } - public static Texture2D Down { get { return GetTexture("down"); } } - public static Texture2D Duplicate { get { return GetTexture("duplicate"); } } - public static Texture2D Up { get { return GetTexture("up"); } } - public static Texture2D ChoiceNodeOff { get { return GetTexture("choice_node_off"); } } - public static Texture2D ChoiceNodeOn { get { return GetTexture("choice_node_on"); } } - public static Texture2D CommandBackground { get { return GetTexture("command_background"); } } - public static Texture2D EventNodeOff { get { return GetTexture("event_node_off"); } } - public static Texture2D EventNodeOn { get { return GetTexture("event_node_on"); } } - public static Texture2D PlayBig { get { return GetTexture("play_big"); } } - public static Texture2D PlaySmall { get { return GetTexture("play_small"); } } - public static Texture2D ProcessNodeOff { get { return GetTexture("process_node_off"); } } - public static Texture2D ProcessNodeOn { get { return GetTexture("process_node_on"); } } - } + public static Texture2D Add { get { return GetTexture("add"); } } + public static Texture2D AddSmall { get { return GetTexture("add_small"); } } + public static Texture2D Delete { get { return GetTexture("delete"); } } + public static Texture2D Down { get { return GetTexture("down"); } } + public static Texture2D Duplicate { get { return GetTexture("duplicate"); } } + public static Texture2D Up { get { return GetTexture("up"); } } + public static Texture2D ChoiceNodeOff { get { return GetTexture("choice_node_off"); } } + public static Texture2D ChoiceNodeOn { get { return GetTexture("choice_node_on"); } } + public static Texture2D CommandBackground { get { return GetTexture("command_background"); } } + public static Texture2D EventNodeOff { get { return GetTexture("event_node_off"); } } + public static Texture2D EventNodeOn { get { return GetTexture("event_node_on"); } } + public static Texture2D PlayBig { get { return GetTexture("play_big"); } } + public static Texture2D PlaySmall { get { return GetTexture("play_small"); } } + public static Texture2D ProcessNodeOff { get { return GetTexture("process_node_off"); } } + public static Texture2D ProcessNodeOn { get { return GetTexture("process_node_on"); } } + } } From 7c31e789b935b6b318205cf0bf6dde8877ec7955 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 10 Nov 2016 15:07:07 +0000 Subject: [PATCH 09/22] Fixed nested while loops don't loop correctly #562 --- Assets/Fungus/Scripts/Commands/End.cs | 6 +- Assets/Tests/Scripting/Scripting.unity | 572 ++++++++++++++++++++++++- 2 files changed, 562 insertions(+), 16 deletions(-) diff --git a/Assets/Fungus/Scripts/Commands/End.cs b/Assets/Fungus/Scripts/Commands/End.cs index 5eb798bf..0ac0c45f 100644 --- a/Assets/Fungus/Scripts/Commands/End.cs +++ b/Assets/Fungus/Scripts/Commands/End.cs @@ -24,8 +24,10 @@ namespace Fungus { for (int i = CommandIndex - 1; i >= 0; --i) { - System.Type commandType = ParentBlock.CommandList[i].GetType(); - if (commandType == typeof(While)) + var command = ParentBlock.CommandList[i]; + + if (command.IndentLevel == IndentLevel && + command.GetType() == typeof(While)) { Continue(i); return; diff --git a/Assets/Tests/Scripting/Scripting.unity b/Assets/Tests/Scripting/Scripting.unity index af30491e..51843ead 100644 --- a/Assets/Tests/Scripting/Scripting.unity +++ b/Assets/Tests/Scripting/Scripting.unity @@ -163,6 +163,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 115525222} + waitForFrames: 1 --- !u!114 &115525222 MonoBehaviour: m_ObjectHideFlags: 2 @@ -181,6 +182,8 @@ MonoBehaviour: y: 70 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -212,7 +215,7 @@ MonoBehaviour: y: -340 width: 1114 height: 859 - selectedBlock: {fileID: 115525222} + selectedBlocks: [] selectedCommands: [] variables: [] description: @@ -301,6 +304,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 169310214} + waitForFrames: 1 --- !u!114 &169310214 MonoBehaviour: m_ObjectHideFlags: 2 @@ -319,6 +323,8 @@ MonoBehaviour: y: 69 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -350,7 +356,7 @@ MonoBehaviour: y: -350 width: 1126 height: 869 - selectedBlock: {fileID: 0} + selectedBlocks: [] selectedCommands: [] variables: [] description: If none of the other Flowcharts have Failed then this one will succeed @@ -404,7 +410,7 @@ MonoBehaviour: y: -340 width: 1114 height: 859 - selectedBlock: {fileID: 0} + selectedBlocks: [] selectedCommands: [] variables: - {fileID: 178675537} @@ -690,6 +696,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 265055379} + waitForFrames: 1 --- !u!114 &265055379 MonoBehaviour: m_ObjectHideFlags: 2 @@ -707,6 +714,8 @@ MonoBehaviour: y: 70 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 1 blockName: BlockB description: The block that does the stopping @@ -733,6 +742,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 265055381} + waitForFrames: 1 --- !u!114 &265055381 MonoBehaviour: m_ObjectHideFlags: 2 @@ -751,6 +761,8 @@ MonoBehaviour: y: 70 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: BlockA description: The block to be stopped @@ -782,7 +794,7 @@ MonoBehaviour: y: -350 width: 1121 height: 869 - selectedBlock: {fileID: 265055379} + selectedBlocks: [] selectedCommands: [] variables: - {fileID: 265055376} @@ -890,7 +902,7 @@ MonoBehaviour: y: -340 width: 1114 height: 892 - selectedBlock: {fileID: 396492930} + selectedBlocks: [] selectedCommands: - {fileID: 396492940} variables: @@ -967,6 +979,8 @@ MonoBehaviour: y: 111 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -1035,6 +1049,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 396492930} + waitForFrames: 1 --- !u!114 &396492934 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1357,6 +1372,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 491823362} + waitForFrames: 1 --- !u!114 &491823362 MonoBehaviour: m_ObjectHideFlags: 2 @@ -1375,6 +1391,8 @@ MonoBehaviour: y: 70 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -1412,7 +1430,8 @@ MonoBehaviour: y: -340 width: 1114 height: 859 - selectedBlock: {fileID: 491823362} + selectedBlocks: + - {fileID: 491823362} selectedCommands: [] variables: - {fileID: 491823359} @@ -1523,6 +1542,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 575910004} + waitForFrames: 1 --- !u!114 &575910004 MonoBehaviour: m_ObjectHideFlags: 2 @@ -1540,6 +1560,8 @@ MonoBehaviour: y: 75 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 2 blockName: New Block description: @@ -1585,6 +1607,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 575910007} + waitForFrames: 1 --- !u!114 &575910007 MonoBehaviour: m_ObjectHideFlags: 2 @@ -1603,6 +1626,8 @@ MonoBehaviour: y: 69 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -1634,7 +1659,7 @@ MonoBehaviour: y: -350 width: 1126 height: 869 - selectedBlock: {fileID: 575910007} + selectedBlocks: [] selectedCommands: [] variables: [] description: Test if interupting a Say command works @@ -1763,6 +1788,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 590474778} + waitForFrames: 1 --- !u!114 &590474778 MonoBehaviour: m_ObjectHideFlags: 2 @@ -1780,6 +1806,8 @@ MonoBehaviour: y: 75 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 2 blockName: New Block description: @@ -1800,6 +1828,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 590474780} + waitForFrames: 1 --- !u!114 &590474780 MonoBehaviour: m_ObjectHideFlags: 2 @@ -1818,6 +1847,8 @@ MonoBehaviour: y: 69 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -1850,7 +1881,7 @@ MonoBehaviour: y: -350 width: 1126 height: 869 - selectedBlock: {fileID: 590474780} + selectedBlocks: [] selectedCommands: - {fileID: 590474773} variables: [] @@ -1933,6 +1964,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 636123607} + waitForFrames: 1 --- !u!114 &636123607 MonoBehaviour: m_ObjectHideFlags: 2 @@ -1951,6 +1983,8 @@ MonoBehaviour: y: 69 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -1983,7 +2017,7 @@ MonoBehaviour: y: -350 width: 1126 height: 869 - selectedBlock: {fileID: 636123607} + selectedBlocks: [] selectedCommands: - {fileID: 636123614} variables: [] @@ -2054,6 +2088,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 636123613} + waitForFrames: 1 --- !u!114 &636123613 MonoBehaviour: m_ObjectHideFlags: 2 @@ -2071,6 +2106,8 @@ MonoBehaviour: y: 75 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 2 blockName: New Block description: @@ -2152,7 +2189,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3} m_Name: m_EditorClassIdentifier: - selectedFlowchart: {fileID: 178675536} + selectedFlowchart: {fileID: 675090867} --- !u!4 &646902075 Transform: m_ObjectHideFlags: 1 @@ -2166,6 +2203,455 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 +--- !u!1 &675090853 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 675090854} + - 114: {fileID: 675090867} + - 114: {fileID: 675090866} + - 114: {fileID: 675090865} + - 114: {fileID: 675090864} + - 114: {fileID: 675090863} + - 114: {fileID: 675090862} + - 114: {fileID: 675090861} + - 114: {fileID: 675090860} + - 114: {fileID: 675090859} + - 114: {fileID: 675090858} + - 114: {fileID: 675090857} + - 114: {fileID: 675090856} + - 114: {fileID: 675090873} + - 114: {fileID: 675090872} + - 114: {fileID: 675090871} + - 114: {fileID: 675090870} + - 114: {fileID: 675090869} + - 114: {fileID: 675090868} + - 114: {fileID: 675090855} + m_Layer: 0 + m_Name: Flowchart + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &675090854 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 1220349165} + m_RootOrder: 0 +--- !u!114 &675090855 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4920f47cde1a84b11ad07b7317568494, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 15 + indentLevel: 0 +--- !u!114 &675090856 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fb77d0ce495044f6e9feb91b31798e8c, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 7 + indentLevel: 1 + variable: {fileID: 675090859} + setOperator: 0 + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 0 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: +--- !u!114 &675090857 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fb77d0ce495044f6e9feb91b31798e8c, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 6 + indentLevel: 2 + variable: {fileID: 675090859} + setOperator: 2 + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 1 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: +--- !u!114 &675090858 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fb77d0ce495044f6e9feb91b31798e8c, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 5 + indentLevel: 1 + variable: {fileID: 675090860} + setOperator: 2 + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 1 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: +--- !u!114 &675090859 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: afb91b566ceda411bad1e9d3c3243ecc, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: j + value: 0 +--- !u!114 &675090860 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: afb91b566ceda411bad1e9d3c3243ecc, type: 3} + m_Name: + m_EditorClassIdentifier: + scope: 0 + key: i + value: 0 +--- !u!114 &675090861 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 93cb9773f2ca04e2bbf7a68ccfc23267, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 4 + indentLevel: 0 +--- !u!114 &675090862 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 663c8a7831a104d16ad7078a4dc2bd10, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 3 + indentLevel: 1 + compareOperator: 2 + variable: {fileID: 675090859} + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 3 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: +--- !u!114 &675090863 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 93cb9773f2ca04e2bbf7a68ccfc23267, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 2 + indentLevel: 1 +--- !u!114 &675090864 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 663c8a7831a104d16ad7078a4dc2bd10, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 1 + indentLevel: 0 + compareOperator: 2 + variable: {fileID: 675090860} + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 3 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: +--- !u!114 &675090865 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 11462346, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3} + m_Name: + m_EditorClassIdentifier: + parentBlock: {fileID: 675090866} + waitForFrames: 1 +--- !u!114 &675090866 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 67 + y: 70 + width: 120 + height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 + itemId: 0 + blockName: Start + description: + eventHandler: {fileID: 675090865} + commandList: + - {fileID: 675090864} + - {fileID: 675090856} + - {fileID: 675090858} + - {fileID: 675090862} + - {fileID: 675090857} + - {fileID: 675090863} + - {fileID: 675090861} + - {fileID: 675090873} + - {fileID: 675090871} + - {fileID: 675090872} + - {fileID: 675090870} + - {fileID: 675090869} + - {fileID: 675090868} + - {fileID: 675090855} +--- !u!114 &675090867 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 1 + scrollPos: {x: 0, y: 0} + variablesScrollPos: {x: 0, y: 0} + variablesExpanded: 1 + blockViewHeight: 400 + zoom: 1 + scrollViewRect: + serializedVersion: 2 + x: -343 + y: -340 + width: 1114 + height: 859 + selectedBlocks: [] + selectedCommands: [] + variables: + - {fileID: 675090860} + - {fileID: 675090859} + description: Check if nested while loops work correctly + stepPause: 0 + colorCommands: 1 + hideComponents: 1 + saveSelection: 1 + localizationId: + showLineNumbers: 0 + hideCommands: [] + luaEnvironment: {fileID: 0} + luaBindingName: flowchart +--- !u!114 &675090868 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 93cb9773f2ca04e2bbf7a68ccfc23267, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 14 + indentLevel: 0 +--- !u!114 &675090869 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2dcb71131f45b47fead560a97ef55f1c, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 13 + indentLevel: 1 + failMessage: +--- !u!114 &675090870 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 70c5622b8a80845c980954170295f292, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 12 + indentLevel: 0 + compareOperator: 1 + variable: {fileID: 675090859} + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 3 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: +--- !u!114 &675090871 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2dcb71131f45b47fead560a97ef55f1c, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 11 + indentLevel: 1 + failMessage: +--- !u!114 &675090872 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 93cb9773f2ca04e2bbf7a68ccfc23267, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 10 + indentLevel: 0 +--- !u!114 &675090873 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 675090853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 70c5622b8a80845c980954170295f292, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 9 + indentLevel: 0 + compareOperator: 1 + variable: {fileID: 675090860} + booleanData: + booleanRef: {fileID: 0} + booleanVal: 0 + integerData: + integerRef: {fileID: 0} + integerVal: 3 + floatData: + floatRef: {fileID: 0} + floatVal: 0 + stringData: + stringRef: {fileID: 0} + stringVal: --- !u!1 &676156674 GameObject: m_ObjectHideFlags: 0 @@ -2613,6 +3099,57 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1141004796} +--- !u!1 &1220349163 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1220349165} + - 114: {fileID: 1220349164} + m_Layer: 0 + m_Name: NestedWhileTest + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1220349164 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1220349163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b1dba0b27b0864740a8720e920aa88c0, type: 3} + m_Name: + m_EditorClassIdentifier: + timeout: 5 + ignored: 0 + succeedAfterAllAssertionsAreExecuted: 0 + expectException: 0 + expectedExceptionList: + succeedWhenExceptionIsThrown: 0 + includedPlatforms: -1 + platformsToIgnore: [] + dynamic: 0 + dynamicTypeName: +--- !u!4 &1220349165 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1220349163} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 675090854} + m_Father: {fileID: 0} + m_RootOrder: 12 --- !u!1 &1314799789 GameObject: m_ObjectHideFlags: 0 @@ -2628,7 +3165,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1314799790 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2892,7 +3429,7 @@ MonoBehaviour: y: -351 width: 1161 height: 873 - selectedBlock: {fileID: 1618689131} + selectedBlocks: [] selectedCommands: - {fileID: 1618689150} variables: @@ -3022,6 +3559,8 @@ MonoBehaviour: y: 69 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Test Invoke description: @@ -3050,6 +3589,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 1618689131} + waitForFrames: 1 --- !u!4 &1618689133 Transform: m_ObjectHideFlags: 0 @@ -3427,6 +3967,8 @@ MonoBehaviour: y: 68 width: 156 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 11 blockName: Test Delayed Invoke description: This block gets executed by last command in Test Invoke @@ -3664,7 +4206,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ba19c26c1ba7243d2b57ebc4329cc7c6, type: 3} m_Name: m_EditorClassIdentifier: - remoteDebugger: 0 --- !u!114 &1753646198 MonoBehaviour: m_ObjectHideFlags: 0 @@ -4103,6 +4644,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: parentBlock: {fileID: 1982550313} + waitForFrames: 1 --- !u!114 &1982550313 MonoBehaviour: m_ObjectHideFlags: 2 @@ -4121,6 +4663,8 @@ MonoBehaviour: y: 70 width: 120 height: 40 + tint: {r: 1, g: 1, b: 1, a: 1} + useCustomTint: 0 itemId: 0 blockName: Start description: @@ -4156,7 +4700,7 @@ MonoBehaviour: y: -340 width: 1114 height: 859 - selectedBlock: {fileID: 1982550313} + selectedBlocks: [] selectedCommands: [] variables: - {fileID: 1982550310} From 344696407de0a07e54dd01a3573efe5aeabf1b8c Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Thu, 10 Nov 2016 08:38:49 -0800 Subject: [PATCH 10/22] Renamed "Fungus Editor Resources" to "EditorResources" --- ...s Editor Resources.meta => EditorResources.meta} | 0 .../Icons.meta | 0 .../Icons/Pro.meta | 0 .../Icons/Pro/add.png | Bin .../Icons/Pro/add.png.meta | 0 .../Icons/Pro/add_small.png | Bin .../Icons/Pro/add_small.png.meta | 0 .../Icons/Pro/delete.png | Bin .../Icons/Pro/delete.png.meta | 0 .../Icons/Pro/down.png | Bin .../Icons/Pro/down.png.meta | 0 .../Icons/Pro/duplicate.png | Bin .../Icons/Pro/duplicate.png.meta | 0 .../Icons/Pro/up.png | Bin .../Icons/Pro/up.png.meta | 0 .../Icons/add.png | Bin .../Icons/add.png.meta | 0 .../Icons/add_small.png | Bin .../Icons/add_small.png.meta | 0 .../Icons/delete.png | Bin .../Icons/delete.png.meta | 0 .../Icons/down.png | Bin .../Icons/down.png.meta | 0 .../Icons/duplicate.png | Bin .../Icons/duplicate.png.meta | 0 .../Icons/up.png | Bin .../Icons/up.png.meta | 0 .../Textures.meta | 0 .../Textures/choice_node_off.png | Bin .../Textures/choice_node_off.png.meta | 0 .../Textures/choice_node_on.png | Bin .../Textures/choice_node_on.png.meta | 0 .../Textures/command_background.png | Bin .../Textures/command_background.png.meta | 0 .../Textures/event_node_off.png | Bin .../Textures/event_node_off.png.meta | 0 .../Textures/event_node_on.png | Bin .../Textures/event_node_on.png.meta | 0 .../Textures/play_big.png | Bin .../Textures/play_big.png.meta | 0 .../Textures/play_small.png | Bin .../Textures/play_small.png.meta | 0 .../Textures/process_node_off.png | Bin .../Textures/process_node_off.png.meta | 0 .../Textures/process_node_on.png | Bin .../Textures/process_node_on.png.meta | 0 .../Fungus/Scripts/Editor/FungusEditorResources.cs | 5 +++-- 47 files changed, 3 insertions(+), 2 deletions(-) rename Assets/Fungus/{Fungus Editor Resources.meta => EditorResources.meta} (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/add.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/add.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/add_small.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/add_small.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/delete.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/delete.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/down.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/down.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/duplicate.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/duplicate.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/up.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/Pro/up.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/add.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/add.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/add_small.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/add_small.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/delete.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/delete.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/down.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/down.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/duplicate.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/duplicate.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/up.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Icons/up.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/choice_node_off.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/choice_node_off.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/choice_node_on.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/choice_node_on.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/command_background.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/command_background.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/event_node_off.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/event_node_off.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/event_node_on.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/event_node_on.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/play_big.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/play_big.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/play_small.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/play_small.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/process_node_off.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/process_node_off.png.meta (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/process_node_on.png (100%) rename Assets/Fungus/{Fungus Editor Resources => EditorResources}/Textures/process_node_on.png.meta (100%) diff --git a/Assets/Fungus/Fungus Editor Resources.meta b/Assets/Fungus/EditorResources.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources.meta rename to Assets/Fungus/EditorResources.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons.meta b/Assets/Fungus/EditorResources/Icons.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons.meta rename to Assets/Fungus/EditorResources/Icons.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro.meta b/Assets/Fungus/EditorResources/Icons/Pro.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro.meta rename to Assets/Fungus/EditorResources/Icons/Pro.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png b/Assets/Fungus/EditorResources/Icons/Pro/add.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png rename to Assets/Fungus/EditorResources/Icons/Pro/add.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/add.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/add.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/add.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add_small.png b/Assets/Fungus/EditorResources/Icons/Pro/add_small.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/add_small.png rename to Assets/Fungus/EditorResources/Icons/Pro/add_small.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/add_small.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/add_small.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/add_small.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/add_small.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png b/Assets/Fungus/EditorResources/Icons/Pro/delete.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png rename to Assets/Fungus/EditorResources/Icons/Pro/delete.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/delete.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/delete.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/delete.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png b/Assets/Fungus/EditorResources/Icons/Pro/down.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png rename to Assets/Fungus/EditorResources/Icons/Pro/down.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/down.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/down.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/down.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png b/Assets/Fungus/EditorResources/Icons/Pro/duplicate.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png rename to Assets/Fungus/EditorResources/Icons/Pro/duplicate.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/duplicate.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/duplicate.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/duplicate.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png b/Assets/Fungus/EditorResources/Icons/Pro/up.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png rename to Assets/Fungus/EditorResources/Icons/Pro/up.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/up.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/Pro/up.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/up.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/add.png b/Assets/Fungus/EditorResources/Icons/add.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/add.png rename to Assets/Fungus/EditorResources/Icons/add.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/add.png.meta b/Assets/Fungus/EditorResources/Icons/add.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/add.png.meta rename to Assets/Fungus/EditorResources/Icons/add.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/add_small.png b/Assets/Fungus/EditorResources/Icons/add_small.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/add_small.png rename to Assets/Fungus/EditorResources/Icons/add_small.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/add_small.png.meta b/Assets/Fungus/EditorResources/Icons/add_small.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/add_small.png.meta rename to Assets/Fungus/EditorResources/Icons/add_small.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/delete.png b/Assets/Fungus/EditorResources/Icons/delete.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/delete.png rename to Assets/Fungus/EditorResources/Icons/delete.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/delete.png.meta b/Assets/Fungus/EditorResources/Icons/delete.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/delete.png.meta rename to Assets/Fungus/EditorResources/Icons/delete.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/down.png b/Assets/Fungus/EditorResources/Icons/down.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/down.png rename to Assets/Fungus/EditorResources/Icons/down.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/down.png.meta b/Assets/Fungus/EditorResources/Icons/down.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/down.png.meta rename to Assets/Fungus/EditorResources/Icons/down.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png b/Assets/Fungus/EditorResources/Icons/duplicate.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png rename to Assets/Fungus/EditorResources/Icons/duplicate.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png.meta b/Assets/Fungus/EditorResources/Icons/duplicate.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/duplicate.png.meta rename to Assets/Fungus/EditorResources/Icons/duplicate.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/up.png b/Assets/Fungus/EditorResources/Icons/up.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/up.png rename to Assets/Fungus/EditorResources/Icons/up.png diff --git a/Assets/Fungus/Fungus Editor Resources/Icons/up.png.meta b/Assets/Fungus/EditorResources/Icons/up.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Icons/up.png.meta rename to Assets/Fungus/EditorResources/Icons/up.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures.meta b/Assets/Fungus/EditorResources/Textures.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures.meta rename to Assets/Fungus/EditorResources/Textures.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png b/Assets/Fungus/EditorResources/Textures/choice_node_off.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png rename to Assets/Fungus/EditorResources/Textures/choice_node_off.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png.meta b/Assets/Fungus/EditorResources/Textures/choice_node_off.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/choice_node_off.png.meta rename to Assets/Fungus/EditorResources/Textures/choice_node_off.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png b/Assets/Fungus/EditorResources/Textures/choice_node_on.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png rename to Assets/Fungus/EditorResources/Textures/choice_node_on.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png.meta b/Assets/Fungus/EditorResources/Textures/choice_node_on.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/choice_node_on.png.meta rename to Assets/Fungus/EditorResources/Textures/choice_node_on.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/command_background.png b/Assets/Fungus/EditorResources/Textures/command_background.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/command_background.png rename to Assets/Fungus/EditorResources/Textures/command_background.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/command_background.png.meta b/Assets/Fungus/EditorResources/Textures/command_background.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/command_background.png.meta rename to Assets/Fungus/EditorResources/Textures/command_background.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png b/Assets/Fungus/EditorResources/Textures/event_node_off.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png rename to Assets/Fungus/EditorResources/Textures/event_node_off.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png.meta b/Assets/Fungus/EditorResources/Textures/event_node_off.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/event_node_off.png.meta rename to Assets/Fungus/EditorResources/Textures/event_node_off.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png b/Assets/Fungus/EditorResources/Textures/event_node_on.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png rename to Assets/Fungus/EditorResources/Textures/event_node_on.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png.meta b/Assets/Fungus/EditorResources/Textures/event_node_on.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/event_node_on.png.meta rename to Assets/Fungus/EditorResources/Textures/event_node_on.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/play_big.png b/Assets/Fungus/EditorResources/Textures/play_big.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/play_big.png rename to Assets/Fungus/EditorResources/Textures/play_big.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/play_big.png.meta b/Assets/Fungus/EditorResources/Textures/play_big.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/play_big.png.meta rename to Assets/Fungus/EditorResources/Textures/play_big.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/play_small.png b/Assets/Fungus/EditorResources/Textures/play_small.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/play_small.png rename to Assets/Fungus/EditorResources/Textures/play_small.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/play_small.png.meta b/Assets/Fungus/EditorResources/Textures/play_small.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/play_small.png.meta rename to Assets/Fungus/EditorResources/Textures/play_small.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png b/Assets/Fungus/EditorResources/Textures/process_node_off.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png rename to Assets/Fungus/EditorResources/Textures/process_node_off.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png.meta b/Assets/Fungus/EditorResources/Textures/process_node_off.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/process_node_off.png.meta rename to Assets/Fungus/EditorResources/Textures/process_node_off.png.meta diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png b/Assets/Fungus/EditorResources/Textures/process_node_on.png similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png rename to Assets/Fungus/EditorResources/Textures/process_node_on.png diff --git a/Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png.meta b/Assets/Fungus/EditorResources/Textures/process_node_on.png.meta similarity index 100% rename from Assets/Fungus/Fungus Editor Resources/Textures/process_node_on.png.meta rename to Assets/Fungus/EditorResources/Textures/process_node_on.png.meta diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index 245de98a..a3c9f948 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -13,6 +13,7 @@ namespace Fungus.EditorUtils internal static partial class FungusEditorResources { private static Dictionary textures = new Dictionary(); + private static readonly string editorResourcesFolderName = "\"EditorResources\""; static FungusEditorResources() { @@ -21,7 +22,7 @@ namespace Fungus.EditorUtils private static void LoadTexturesFromNames() { - var baseDirectories = AssetDatabase.FindAssets("\"Fungus Editor Resources\"").Select( + var baseDirectories = AssetDatabase.FindAssets(editorResourcesFolderName).Select( guid => AssetDatabase.GUIDToAssetPath(guid) ).ToArray(); @@ -33,7 +34,7 @@ namespace Fungus.EditorUtils private static void LoadAllTexturesInFolder() { - var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0]; + var rootGuid = AssetDatabase.FindAssets(editorResourcesFolderName)[0]; var root = AssetDatabase.GUIDToAssetPath(rootGuid); LoadTexturesFromGUIDs(AssetDatabase.FindAssets("t:Texture2D", new [] { root })); } From 07d0122b7263799fdc41bb540194d91974e6ec26 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Fri, 11 Nov 2016 22:54:25 -0800 Subject: [PATCH 11/22] Updated curves, connection points, and grid background -Replaced GLDraw calls with Handles calls for connection curves -Replaced GUI.Label calls with GUI.DrawTexture calls for connection points -Replaced GUI.DrawTexture with native graph background draw call -Removed GLDraw.cs --- .../Textures/connection_point.png | Bin 0 -> 982 bytes .../Textures/connection_point.png.meta | 59 ++++ .../Fungus/Scripts/Editor/FlowchartWindow.cs | 105 +++++-- .../Editor/FungusEditorResourcesGenerated.cs | 2 + Assets/Fungus/Scripts/Editor/GLDraw.cs | 292 ------------------ Assets/Fungus/Scripts/Editor/GLDraw.cs.meta | 8 - 6 files changed, 132 insertions(+), 334 deletions(-) create mode 100644 Assets/Fungus/EditorResources/Textures/connection_point.png create mode 100644 Assets/Fungus/EditorResources/Textures/connection_point.png.meta delete mode 100644 Assets/Fungus/Scripts/Editor/GLDraw.cs delete mode 100644 Assets/Fungus/Scripts/Editor/GLDraw.cs.meta diff --git a/Assets/Fungus/EditorResources/Textures/connection_point.png b/Assets/Fungus/EditorResources/Textures/connection_point.png new file mode 100644 index 0000000000000000000000000000000000000000..5a6719e7e1adf90939117b0a0c5403c854f02fcd GIT binary patch literal 982 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKV3f`bi71Ki^|4CM&(%vz$xlkv ztH>-n*TA>HIW;5GqpB!1xXLdi zxhgx^GDXSWj?1RP3TQxXYDuC(MQ%=Bu~mhw64+cTAR8pCucQE0Qj%?}6yY17;GAES zs$i;Ts%M~N$E9FXl#*r@k>g7FXt#Bv$C=6)S^`fSBQuTAW;zSx}OhpQivaGchT@w8U0PNgrg1KGYVVbM@iw z1#;j%PR#>)vk2%PDX-P9fWg$7>FgX(9OUk#;OXjYW@u?t+)-)8P3t=JN+%w|if>;^#X5r>ow7U%xfyh%c|q*+Y+K^Qt zl0NkOP@S`$#-9~mB3k1`)la_(vD|wsNk!$2=r`4Di?G8{r%rJ2bC;)Is(kz1?v?7= zk8dtDU0Pb6D3sWxV3#&Syh+uQ%FHoko?v}1|h^`lue z>o^wYFA`rB_1&%4RL!N$k8(EX3?Yx{34>Bh`6=7AC?XMsm#F#`j)FbFd;%$g$s6ujW+;uvDlyY{kS z-XRBp)`#b#mwvFkwCte(qpGc?i$~C|g4QX_6Pyn)Dm`+(u;i(XN5Dc6xdWRRPV((H zIh%F=^0_yAe7cXnd?u$a;c`$bD{kt~U6uCP9K!cLbnf0(xWTzGGW6N+#f}~O4fiPI zY(7#9u)^l9K^q7bwtLolbM%lCGH$~5U=vJ=}T&df_a#d9AnJMK9m{#C%$VBUv^Ro2max@9hSJZ_A5yYX{j+?L0G Y*p<31`14sCZ-9L4>FVdQ&MBb@0GeZ*{{R30 literal 0 HcmV?d00001 diff --git a/Assets/Fungus/EditorResources/Textures/connection_point.png.meta b/Assets/Fungus/EditorResources/Textures/connection_point.png.meta new file mode 100644 index 00000000..51982bb8 --- /dev/null +++ b/Assets/Fungus/EditorResources/Textures/connection_point.png.meta @@ -0,0 +1,59 @@ +fileFormatVersion: 2 +guid: f08a4c27d7efe4aa6a35348a4e8aec8f +timeCreated: 1478932274 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index c11ac1bd..2ceac788 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -34,11 +34,15 @@ namespace Fungus.EditorUtils protected int forceRepaintCount; protected Texture2D addTexture; + protected Texture2D connectionPointTexture; protected Rect selectionBox; protected Vector2 startSelectionBoxPosition = -Vector2.one; protected List mouseDownSelectionState = new List(); + protected Color gridLineColor = Color.black; + protected readonly Color connectionColor = new Color(0.65f, 0.65f, 0.65f, 1.0f); + // Context Click occurs on MouseDown which interferes with panning // Track right click positions manually to show menus on MouseUp protected Vector2 rightClickDown = -Vector2.one; @@ -66,6 +70,8 @@ namespace Fungus.EditorUtils nodeStyle.wordWrap = true; addTexture = FungusEditorResources.AddSmall; + connectionPointTexture = FungusEditorResources.ConnectionPoint; + gridLineColor.a = EditorGUIUtility.isProSkin ? 0.5f : 0.25f; } protected virtual void OnInspectorUpdate() @@ -299,6 +305,13 @@ namespace Fungus.EditorUtils flowchart.ScrollViewRect = newRect; } + // Draw background color / drop shadow + if (Event.current.type == EventType.Repaint) + { + UnityEditor.Graphs.Styles.graphBackground.Draw( + new Rect(0, 17, position.width, position.height - 17), false, false, false, false + ); + } // Calc rect for script view Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.Zoom, this.position.height / flowchart.Zoom); @@ -320,10 +333,11 @@ namespace Fungus.EditorUtils EditorZoomArea.Begin(flowchart.Zoom, scriptViewRect); - DrawGrid(flowchart); + if (Event.current.type == EventType.Repaint) + { + DrawGrid(flowchart); + } - GLDraw.BeginGroup(scriptViewRect); - // The center of the Flowchart depends on the block positions and window dimensions, so we calculate it // here in the FlowchartWindow class and store it on the Flowchart object for use later. if (flowchart != null && blocks.Length > 0) @@ -485,8 +499,6 @@ namespace Fungus.EditorUtils PanAndZoom(flowchart); - GLDraw.EndGroup(); - EditorZoomArea.End(); // Handle right click up outside of EditorZoomArea to avoid strange offsets @@ -720,26 +732,14 @@ namespace Fungus.EditorUtils float width = this.position.width / flowchart.Zoom; float height = this.position.height / flowchart.Zoom; - // Match background color of scene view - if (EditorGUIUtility.isProSkin) - { - GUI.color = new Color32(71, 71, 71, 255); - } - else - { - GUI.color = new Color32(86, 86, 86, 255); - } - GUI.DrawTexture( new Rect(0,0, width, height), EditorGUIUtility.whiteTexture ); - - GUI.color = Color.white; - Color color = new Color32(96, 96, 96, 255); + Handles.color = gridLineColor; float gridSize = 128f; float x = flowchart.ScrollPos.x % gridSize; while (x < width) { - GLDraw.DrawLine(new Vector2(x, 0), new Vector2(x, height), color, 1f); + Handles.DrawLine(new Vector2(x, 0), new Vector2(x, height)); x += gridSize; } @@ -748,10 +748,12 @@ namespace Fungus.EditorUtils { if (y >= 0) { - GLDraw.DrawLine(new Vector2(0, y), new Vector2(width, y), color, 1f); + Handles.DrawLine(new Vector2(0, y), new Vector2(width, y)); } y += gridSize; } + + Handles.color = Color.white; } protected virtual void SelectBlock(Flowchart flowchart, Block block) @@ -990,17 +992,17 @@ namespace Fungus.EditorUtils protected virtual void DrawRectConnection(Rect rectA, Rect rectB, bool highlight) { Vector2[] pointsA = new Vector2[] { - new Vector2(rectA.xMin + 5, rectA.center.y), - new Vector2(rectA.xMin + rectA.width / 2, rectA.yMin + 2), - new Vector2(rectA.xMin + rectA.width / 2, rectA.yMax - 2), - new Vector2(rectA.xMax - 5, rectA.center.y) + new Vector2(rectA.xMin, rectA.center.y), + new Vector2(rectA.xMin + rectA.width / 2, rectA.yMin), + new Vector2(rectA.xMin + rectA.width / 2, rectA.yMax), + new Vector2(rectA.xMax, rectA.center.y) }; Vector2[] pointsB = new Vector2[] { - new Vector2(rectB.xMin + 5, rectB.center.y), - new Vector2(rectB.xMin + rectB.width / 2, rectB.yMin + 2), - new Vector2(rectB.xMin + rectB.width / 2, rectB.yMax - 2), - new Vector2(rectB.xMax - 5, rectB.center.y) + new Vector2(rectB.xMin, rectB.center.y), + new Vector2(rectB.xMin + rectB.width / 2, rectB.yMin), + new Vector2(rectB.xMin + rectB.width / 2, rectB.yMax), + new Vector2(rectB.xMax, rectB.center.y) }; Vector2 pointA = Vector2.zero; @@ -1021,19 +1023,54 @@ namespace Fungus.EditorUtils } } - Color color = Color.grey; + Color color = connectionColor; if (highlight) { color = Color.green; } - GLDraw.DrawConnectingCurve(pointA, pointB, color, 1.025f); + Handles.color = color; + + // Place control based on distance between points + // Weight the min component more so things don't get overly curvy + var diff = pointA - pointB; + diff.x = Mathf.Abs(diff.x); + diff.y = Mathf.Abs(diff.y); + var min = Mathf.Min(diff.x, diff.y); + var max = Mathf.Max(diff.x, diff.y); + var mod = min * 0.75f + max * 0.25f; + + // Draw bezier curve connecting blocks + var directionA = (rectA.center - pointA).normalized; + var directionB = (rectB.center - pointB).normalized; + var controlA = pointA - directionA * mod * 0.67f; + var controlB = pointB - directionB * mod * 0.67f; + Handles.DrawBezier(pointA, pointB, controlA, controlB, color, null, 3f); + + // Draw arrow on curve + var point = GetPointOnCurve(pointA, controlA, pointB, controlB, 0.7f); + var direction = (GetPointOnCurve(pointA, controlA, pointB, controlB, 0.6f) - point).normalized; + var perp = new Vector2(direction.y, -direction.x); + Handles.DrawAAConvexPolygon( + point, point + direction * 10 + perp * 5, point + direction * 10 - perp * 5 + ); + + var connectionPointA = pointA + directionA * 4f; + var connectionRectA = new Rect(connectionPointA.x - 4f, connectionPointA.y - 4f, 8f, 8f); + var connectionPointB = pointB + directionB * 4f; + var connectionRectB = new Rect(connectionPointB.x - 4f, connectionPointB.y - 4f, 8f, 8f); - Rect dotARect = new Rect(pointA.x - 5, pointA.y - 5, 10, 10); - GUI.Label(dotARect, "", new GUIStyle("U2D.dragDotActive")); + GUI.DrawTexture(connectionRectA, connectionPointTexture, ScaleMode.ScaleToFit); + GUI.DrawTexture(connectionRectB, connectionPointTexture, ScaleMode.ScaleToFit); - Rect dotBRect = new Rect(pointB.x - 5, pointB.y - 5, 10, 10); - GUI.Label(dotBRect, "", new GUIStyle("U2D.dragDotActive")); + Handles.color = Color.white; + } + + private static Vector2 GetPointOnCurve(Vector2 s, Vector2 st, Vector2 e, Vector2 et, float t) + { + float rt = 1 - t; + float rtt = rt * t; + return rt * rt * rt * s + 3 * rt * rtt * st + 3 * rtt * t * et + t * t * t * e; } public static void DeleteBlocks(object obj) diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs index e2eab920..c7ea8069 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -17,6 +17,7 @@ namespace Fungus.EditorUtils "choice_node_off", "choice_node_on", "command_background", + "connection_point", "event_node_off", "event_node_on", "play_big", @@ -34,6 +35,7 @@ namespace Fungus.EditorUtils public static Texture2D ChoiceNodeOff { get { return GetTexture("choice_node_off"); } } public static Texture2D ChoiceNodeOn { get { return GetTexture("choice_node_on"); } } public static Texture2D CommandBackground { get { return GetTexture("command_background"); } } + public static Texture2D ConnectionPoint { get { return GetTexture("connection_point"); } } public static Texture2D EventNodeOff { get { return GetTexture("event_node_off"); } } public static Texture2D EventNodeOn { get { return GetTexture("event_node_on"); } } public static Texture2D PlayBig { get { return GetTexture("play_big"); } } diff --git a/Assets/Fungus/Scripts/Editor/GLDraw.cs b/Assets/Fungus/Scripts/Editor/GLDraw.cs deleted file mode 100644 index 9ef5b222..00000000 --- a/Assets/Fungus/Scripts/Editor/GLDraw.cs +++ /dev/null @@ -1,292 +0,0 @@ -// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). -// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) - -using UnityEngine; - -namespace Fungus.EditorUtils -{ - /// - /// Clipping code: http://forum.unity3d.com/threads/17066-How-to-draw-a-GUI-2D-quot-line-quot?p=230386#post230386 - /// Thick line drawing code: http://unifycommunity.com/wiki/index.php?title=VectorLine - /// Credit: "http://cs-people.bu.edu/jalon/cs480/Oct11Lab/clip.c" - /// - public class GLDraw - { - protected static bool clippingEnabled; - protected static Rect clippingBounds; - public static Material lineMaterial = null; - - protected static bool clip_test(float p, float q, ref float u1, ref float u2) - { - float r; - bool retval = true; - - if (p < 0.0) - { - r = q / p; - if (r > u2) - retval = false; - else if (r > u1) - u1 = r; - } - else if (p > 0.0) - { - r = q / p; - if (r < u1) - retval = false; - else if (r < u2) - u2 = r; - } - else if (q < 0.0) - retval = false; - - return retval; - } - - public static bool segment_rect_intersection(Rect bounds, ref Vector2 p1, ref Vector2 p2) - { - float u1 = 0.0f, u2 = 1.0f, dx = p2.x - p1.x, dy; - - if (clip_test(-dx, p1.x - bounds.xMin, ref u1, ref u2)) - { - if (clip_test(dx, bounds.xMax - p1.x, ref u1, ref u2)) - { - dy = p2.y - p1.y; - if (clip_test(-dy, p1.y - bounds.yMin, ref u1, ref u2)) - { - if (clip_test(dy, bounds.yMax - p1.y, ref u1, ref u2)) - { - if (u2 < 1.0) - { - p2.x = p1.x + u2 * dx; - p2.y = p1.y + u2 * dy; - } - - if (u1 > 0.0) - { - p1.x += u1 * dx; - p1.y += u1 * dy; - } - return true; - } - } - } - } - return false; - } - - public static void BeginGroup(Rect position) - { - clippingEnabled = true; - clippingBounds = new Rect(0, 0, position.width, position.height); - GUI.BeginGroup(position); - } - - public static void EndGroup() - { - GUI.EndGroup(); - clippingBounds = new Rect(0, 0, Screen.width, Screen.height); - clippingEnabled = false; - } - - public static Vector2 BeginScrollView(Rect position, Vector2 scrollPos, Rect viewRect, Rect clipRect) - { - clippingEnabled = true; - clippingBounds = clipRect; - return GUI.BeginScrollView(position, scrollPos, viewRect, GUIStyle.none, GUIStyle.none); - } - - public static void EndScrollView() - { - GUI.EndScrollView(); - clippingBounds = new Rect(0, 0, Screen.width, Screen.height); - clippingEnabled = false; - } - - public static void CreateMaterial() - { - if (lineMaterial != null) - return; - - lineMaterial = Resources.Load("GLLineDraw", typeof(Material)) as Material; - } - - public static void DrawLine(Vector2 start, Vector2 end, Color color, float width) - { - if (Event.current == null) - return; - if (Event.current.type != EventType.repaint) - return; - - if (clippingEnabled) - if (!segment_rect_intersection(clippingBounds, ref start, ref end)) - return; - - CreateMaterial(); - - lineMaterial.SetPass(0); - - Vector3 startPt; - Vector3 endPt; - - if (width == 1) - { - GL.Begin(GL.LINES); - GL.Color(color); - startPt = new Vector3(start.x, start.y, 0); - endPt = new Vector3(end.x, end.y, 0); - GL.Vertex(startPt); - GL.Vertex(endPt); - } - else - { - GL.Begin(GL.QUADS); - GL.Color(color); - startPt = new Vector3(end.y, start.x, 0); - endPt = new Vector3(start.y, end.x, 0); - Vector3 perpendicular = (startPt - endPt).normalized * width; - Vector3 v1 = new Vector3(start.x, start.y, 0); - Vector3 v2 = new Vector3(end.x, end.y, 0); - GL.Vertex(v1 - perpendicular); - GL.Vertex(v1 + perpendicular); - GL.Vertex(v2 + perpendicular); - GL.Vertex(v2 - perpendicular); - } - GL.End(); - } - - public static void DrawRect(Rect rect, Color color) - { - if (Event.current == null) - return; - if (Event.current.type != EventType.repaint) - return; - - CreateMaterial(); - // set the current material - lineMaterial.SetPass( 0 ); - GL.Begin( GL.QUADS ); - GL.Color( color ); - GL.Vertex3( rect.xMin, rect.yMin, 0 ); - GL.Vertex3( rect.xMax, rect.yMin, 0 ); - GL.Vertex3( rect.xMax, rect.yMax, 0 ); - GL.Vertex3( rect.xMin, rect.yMax, 0 ); - GL.End(); - } - - public static void DrawBox(Rect box, Color color, float width) - { - Vector2 p1 = new Vector2(box.xMin, box.yMin); - Vector2 p2 = new Vector2(box.xMax, box.yMin); - Vector2 p3 = new Vector2(box.xMax, box.yMax); - Vector2 p4 = new Vector2(box.xMin, box.yMax); - DrawLine(p1, p2, color, width); - DrawLine(p2, p3, color, width); - DrawLine(p3, p4, color, width); - DrawLine(p4, p1, color, width); - } - - public static void DrawBox(Vector2 topLeftCorner, Vector2 bottomRightCorner, Color color, float width) - { - Rect box = new Rect(topLeftCorner.x, topLeftCorner.y, bottomRightCorner.x - topLeftCorner.x, bottomRightCorner.y - topLeftCorner.y); - DrawBox(box, color, width); - } - - public static void DrawRoundedBox(Rect box, float radius, Color color, float width) - { - Vector2 p1, p2, p3, p4, p5, p6, p7, p8; - p1 = new Vector2(box.xMin + radius, box.yMin); - p2 = new Vector2(box.xMax - radius, box.yMin); - p3 = new Vector2(box.xMax, box.yMin + radius); - p4 = new Vector2(box.xMax, box.yMax - radius); - p5 = new Vector2(box.xMax - radius, box.yMax); - p6 = new Vector2(box.xMin + radius, box.yMax); - p7 = new Vector2(box.xMin, box.yMax - radius); - p8 = new Vector2(box.xMin, box.yMin + radius); - - DrawLine(p1, p2, color, width); - DrawLine(p3, p4, color, width); - DrawLine(p5, p6, color, width); - DrawLine(p7, p8, color, width); - - Vector2 t1, t2; - float halfRadius = radius / 2; - - t1 = new Vector2(p8.x, p8.y + halfRadius); - t2 = new Vector2(p1.x - halfRadius, p1.y); - DrawBezier(p8, t1, p1, t2, color, width); - - t1 = new Vector2(p2.x + halfRadius, p2.y); - t2 = new Vector2(p3.x, p3.y - halfRadius); - DrawBezier(p2, t1, p3, t2, color, width); - - t1 = new Vector2(p4.x, p4.y + halfRadius); - t2 = new Vector2(p5.x + halfRadius, p5.y); - DrawBezier(p4, t1, p5, t2, color, width); - - t1 = new Vector2(p6.x - halfRadius, p6.y); - t2 = new Vector2(p7.x, p7.y + halfRadius); - DrawBezier(p6, t1, p7, t2, color, width); - } - - public static void DrawConnectingCurve(Vector2 start, Vector2 end, Color color, float width) - { - Vector2 distance = start - end; - - Vector2 tangentA = start; - tangentA.x -= distance.x * 0.5f; - Vector2 tangentB = end; - tangentB.x += distance.x * 0.5f; - - int segments = Mathf.FloorToInt((distance.magnitude / 20) * 3); - - DrawBezier(start, tangentA, end, tangentB, color, width, segments); - - Vector2 pA = CubeBezier(start, tangentA, end, tangentB, 0.6f); - Vector2 pB = CubeBezier(start, tangentA, end, tangentB, 0.7f); - - float arrowHeadSize = 5; - - Vector2 arrowPosA = pB; - Vector2 arrowPosB = arrowPosA; - Vector2 arrowPosC = arrowPosA; - - Vector2 dir = (pB - pA).normalized; - - arrowPosB.x += dir.y * arrowHeadSize; - arrowPosB.y -= dir.x * arrowHeadSize; - arrowPosB -= dir * arrowHeadSize; - - arrowPosC.x -= dir.y * arrowHeadSize; - arrowPosC.y += dir.x * arrowHeadSize; - arrowPosC -= dir * arrowHeadSize; - - DrawLine(arrowPosA, arrowPosB, color, 1.025f); - DrawLine(arrowPosA, arrowPosC, color, 1.025f); - } - - public static void DrawBezier(Vector2 start, Vector2 startTangent, Vector2 end, Vector2 endTangent, Color color, float width) - { - int segments = Mathf.FloorToInt((start - end).magnitude / 20) * 3; // Three segments per distance of 20 - DrawBezier(start, startTangent, end, endTangent, color, width, segments); - } - - public static void DrawBezier(Vector2 start, Vector2 startTangent, Vector2 end, Vector2 endTangent, Color color, float width, int segments) - { - Vector2 startVector = CubeBezier(start, startTangent, end, endTangent, 0); - for (int i = 1; i <= segments; i++) - { - Vector2 endVector = CubeBezier(start, startTangent, end, endTangent, i / (float)segments); - DrawLine(startVector, endVector, color, width); - startVector = endVector; - } - } - - private static Vector2 CubeBezier(Vector2 s, Vector2 st, Vector2 e, Vector2 et, float t) - { - float rt = 1 - t; - float rtt = rt * t; - return rt * rt * rt * s + 3 * rt * rtt * st + 3 * rtt * t * et + t * t * t * e; - } - } -} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Editor/GLDraw.cs.meta b/Assets/Fungus/Scripts/Editor/GLDraw.cs.meta deleted file mode 100644 index 6f3fb05c..00000000 --- a/Assets/Fungus/Scripts/Editor/GLDraw.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5184535fd41514a0ebd42c1d70a53545 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: From 5ddb670ef88531a2304ebf0203263525c30c039f Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Sat, 12 Nov 2016 09:38:21 -0800 Subject: [PATCH 12/22] Removed unused GLLineDraw resources --- Assets/Fungus/Resources/GLLineDraw.mat | 138 ------------------ Assets/Fungus/Resources/GLLineDraw.mat.meta | 8 - Assets/Fungus/Resources/GLLineDraw.shader | 11 -- .../Fungus/Resources/GLLineDraw.shader.meta | 9 -- 4 files changed, 166 deletions(-) delete mode 100644 Assets/Fungus/Resources/GLLineDraw.mat delete mode 100644 Assets/Fungus/Resources/GLLineDraw.mat.meta delete mode 100644 Assets/Fungus/Resources/GLLineDraw.shader delete mode 100644 Assets/Fungus/Resources/GLLineDraw.shader.meta diff --git a/Assets/Fungus/Resources/GLLineDraw.mat b/Assets/Fungus/Resources/GLLineDraw.mat deleted file mode 100644 index d6af24a8..00000000 --- a/Assets/Fungus/Resources/GLLineDraw.mat +++ /dev/null @@ -1,138 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!21 &2100000 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GLLineDraw - m_Shader: {fileID: 4800000, guid: ef64b0d30343049d4a634192975fab73, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 5 - m_CustomRenderQueue: -1 - stringTagMap: {} - m_SavedProperties: - serializedVersion: 2 - m_TexEnvs: - data: - first: - name: _MainTex - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _BumpMap - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _DetailNormalMap - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _ParallaxMap - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _OcclusionMap - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _EmissionMap - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _DetailMask - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _DetailAlbedoMap - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - data: - first: - name: _MetallicGlossMap - second: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - data: - first: - name: _SrcBlend - second: 1 - data: - first: - name: _DstBlend - second: 0 - data: - first: - name: _Cutoff - second: .5 - data: - first: - name: _Parallax - second: .0199999996 - data: - first: - name: _ZWrite - second: 1 - data: - first: - name: _Glossiness - second: .5 - data: - first: - name: _BumpScale - second: 1 - data: - first: - name: _OcclusionStrength - second: 1 - data: - first: - name: _DetailNormalMapScale - second: 1 - data: - first: - name: _UVSec - second: 0 - data: - first: - name: _Mode - second: 0 - data: - first: - name: _Metallic - second: 0 - m_Colors: - data: - first: - name: _EmissionColor - second: {r: 0, g: 0, b: 0, a: 1} - data: - first: - name: _Color - second: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Fungus/Resources/GLLineDraw.mat.meta b/Assets/Fungus/Resources/GLLineDraw.mat.meta deleted file mode 100644 index 9d6a27d2..00000000 --- a/Assets/Fungus/Resources/GLLineDraw.mat.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4209d966cfca44792ad45389a996015e -timeCreated: 1434115586 -licenseType: Free -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Fungus/Resources/GLLineDraw.shader b/Assets/Fungus/Resources/GLLineDraw.shader deleted file mode 100644 index 761be92f..00000000 --- a/Assets/Fungus/Resources/GLLineDraw.shader +++ /dev/null @@ -1,11 +0,0 @@ -Shader "Lines/Colored Blended" { - SubShader { - Pass { - Blend SrcAlpha OneMinusSrcAlpha - ZWrite Off Cull Off Fog { Mode Off } - BindChannels { - Bind "vertex", vertex Bind "color", color - } - } - } -} diff --git a/Assets/Fungus/Resources/GLLineDraw.shader.meta b/Assets/Fungus/Resources/GLLineDraw.shader.meta deleted file mode 100644 index e94f8e19..00000000 --- a/Assets/Fungus/Resources/GLLineDraw.shader.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: ef64b0d30343049d4a634192975fab73 -timeCreated: 1434114816 -licenseType: Free -ShaderImporter: - defaultTextures: [] - userData: - assetBundleName: - assetBundleVariant: From c61f4b05ce4cf8333ccc94c0d36ca4ec24a2114e Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Sat, 12 Nov 2016 11:20:54 -0800 Subject: [PATCH 13/22] EditorResources now uses SerializedObject to maintain asset references --- .../FungusEditorResources.asset | 59 ++++++ .../FungusEditorResources.asset.meta | 8 + .../Scripts/Editor/FungusEditorResources.cs | 171 +++++++++++++----- .../Editor/FungusEditorResourcesGenerated.cs | 64 ++++--- 4 files changed, 222 insertions(+), 80 deletions(-) create mode 100644 Assets/Fungus/EditorResources/FungusEditorResources.asset create mode 100644 Assets/Fungus/EditorResources/FungusEditorResources.asset.meta diff --git a/Assets/Fungus/EditorResources/FungusEditorResources.asset b/Assets/Fungus/EditorResources/FungusEditorResources.asset new file mode 100644 index 00000000..f8d40f35 --- /dev/null +++ b/Assets/Fungus/EditorResources/FungusEditorResources.asset @@ -0,0 +1,59 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d2af387304e4b454b9ce8b815799cad0, type: 3} + m_Name: FungusEditorResources + m_EditorClassIdentifier: + updateOnReloadScripts: 0 + add: + free: {fileID: 2800000, guid: 24a867d6b4cdda04cb3aa3350f9ec7d0, type: 3} + pro: {fileID: 2800000, guid: 4e43c476b4a7a49a08c37378fb01ce99, type: 3} + add_small: + free: {fileID: 2800000, guid: 288aff1a0e5c14fd3a0039d24149df73, type: 3} + pro: {fileID: 2800000, guid: 64534dfaa17844231a9a9dd2df89d0db, type: 3} + delete: + free: {fileID: 2800000, guid: d6fc8a97e8a5b0947a49b780f787e504, type: 3} + pro: {fileID: 2800000, guid: 29c4d29b1678042a5b3516c732ccc507, type: 3} + down: + free: {fileID: 2800000, guid: 51a973f446c2e664582861480cce6215, type: 3} + pro: {fileID: 2800000, guid: 5a87a7d3683164a238377d948572805f, type: 3} + duplicate: + free: {fileID: 2800000, guid: c97f334c466215a4f93eff31de3c1591, type: 3} + pro: {fileID: 2800000, guid: 2f17490d993c84bd7872ef6588ffba47, type: 3} + up: + free: {fileID: 2800000, guid: 8f1242ad894201f43b2b6d52fd990f77, type: 3} + pro: {fileID: 2800000, guid: 2a76a781db2994b33b83cd84b8835da7, type: 3} + choice_node_off: + free: {fileID: 2800000, guid: 7b6fc04aac74540e39e9502da5312ce7, type: 3} + pro: {fileID: 0} + choice_node_on: + free: {fileID: 2800000, guid: cfc05494b71a0446182868aab5f7febf, type: 3} + pro: {fileID: 0} + command_background: + free: {fileID: 2800000, guid: a5c9a4271b3de4e4f86eff7f8a1bd768, type: 3} + pro: {fileID: 0} + event_node_off: + free: {fileID: 2800000, guid: 0e16a209826864df7b05f6d3901aae7a, type: 3} + pro: {fileID: 0} + event_node_on: + free: {fileID: 2800000, guid: 9434488a4efb54da5986eba5d5619baf, type: 3} + pro: {fileID: 0} + play_big: + free: {fileID: 2800000, guid: bff2ba39f5f4448589e80522ebfcd0a0, type: 3} + pro: {fileID: 0} + play_small: + free: {fileID: 2800000, guid: a48a2b9b06deb469d9da1777b094521b, type: 3} + pro: {fileID: 0} + process_node_off: + free: {fileID: 2800000, guid: ea3a4228e6c214149bfe5c741b56ae0c, type: 3} + pro: {fileID: 0} + process_node_on: + free: {fileID: 2800000, guid: c2dceb780784240ccbe8d3cde89f7671, type: 3} + pro: {fileID: 0} diff --git a/Assets/Fungus/EditorResources/FungusEditorResources.asset.meta b/Assets/Fungus/EditorResources/FungusEditorResources.asset.meta new file mode 100644 index 00000000..c92acc45 --- /dev/null +++ b/Assets/Fungus/EditorResources/FungusEditorResources.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29cae11326cb84802b83fc3ff25a47e8 +timeCreated: 1478978272 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index a3c9f948..109c3dda 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -3,6 +3,7 @@ using UnityEngine; using UnityEditor; +using UnityEditor.Callbacks; using System; using System.IO; using System.Linq; @@ -10,58 +11,102 @@ using System.Collections.Generic; namespace Fungus.EditorUtils { - internal static partial class FungusEditorResources + [CustomEditor(typeof(FungusEditorResources))] + internal class FungusEditorResourcesInspector : Editor { - private static Dictionary textures = new Dictionary(); - private static readonly string editorResourcesFolderName = "\"EditorResources\""; - - static FungusEditorResources() + public override void OnInspectorGUI() { - LoadTexturesFromNames(); + if (serializedObject.FindProperty("updateOnReloadScripts").boolValue) + { + GUILayout.Label("Updating..."); + } + else + { + if (GUILayout.Button("Sync with EditorResources folder")) + { + FungusEditorResources.GenerateResourcesScript(); + } + + DrawDefaultInspector(); + } } + } - private static void LoadTexturesFromNames() + internal partial class FungusEditorResources : ScriptableObject + { + [Serializable] + internal class EditorTexture { - var baseDirectories = AssetDatabase.FindAssets(editorResourcesFolderName).Select( - guid => AssetDatabase.GUIDToAssetPath(guid) - ).ToArray(); - - foreach (var name in resourceNames) + [SerializeField] private Texture2D free; + [SerializeField] private Texture2D pro; + + public Texture2D Texture2D { - LoadTexturesFromGUIDs(AssetDatabase.FindAssets(name + " t:Texture2D", baseDirectories)); + get { return EditorGUIUtility.isProSkin && pro != null ? pro : free; } } - } - private static void LoadAllTexturesInFolder() - { - var rootGuid = AssetDatabase.FindAssets(editorResourcesFolderName)[0]; - var root = AssetDatabase.GUIDToAssetPath(rootGuid); - LoadTexturesFromGUIDs(AssetDatabase.FindAssets("t:Texture2D", new [] { root })); + public EditorTexture(Texture2D free, Texture2D pro) + { + this.free = free; + this.pro = pro; + } } - private static void LoadTexturesFromGUIDs(string[] guids) + private static FungusEditorResources instance; + private static readonly string editorResourcesFolderName = "\"EditorResources\""; + [SerializeField] [HideInInspector] private bool updateOnReloadScripts = false; + + internal static FungusEditorResources Instance { - var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/")); - - foreach (var path in paths) + get { - if (path.ToLower().Contains("/pro/") && !EditorGUIUtility.isProSkin) + if (instance == null) { - return; + var guids = AssetDatabase.FindAssets("FungusEditorResources t:FungusEditorResources"); + + if (guids.Length == 0) + { + instance = ScriptableObject.CreateInstance(typeof(FungusEditorResources)) as FungusEditorResources; + AssetDatabase.CreateAsset(instance, GetRootFolder() + "/FungusEditorResources.asset"); + UpdateTextureReferences(instance); + AssetDatabase.SaveAssets(); + } + else + { + if (guids.Length > 1) + { + Debug.LogWarning("Multiple FungusEditorResources assets found!"); + } + + var path = AssetDatabase.GUIDToAssetPath(guids[0]); + instance = AssetDatabase.LoadAssetAtPath(path, typeof(FungusEditorResources)) as FungusEditorResources; + } } - var texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D; - textures[texture.name] = texture; + + return instance; } } - [MenuItem("Tools/Fungus/Utilities/Update Editor Resources Script")] - private static void GenerateResourcesScript() + private static string GetRootFolder() { - textures.Clear(); - LoadAllTexturesInFolder(); + var rootGuid = AssetDatabase.FindAssets(editorResourcesFolderName)[0]; + return AssetDatabase.GUIDToAssetPath(rootGuid); + } - var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0]; - var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs"); + internal static void GenerateResourcesScript() + { + // Get all unique filenames + var textureNames = new HashSet(); + var guids = AssetDatabase.FindAssets("t:Texture2D", new [] { GetRootFolder() }); + var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)); + + foreach (var path in paths) + { + textureNames.Add(Path.GetFileNameWithoutExtension(path)); + } + + var scriptGuid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0]; + var relativePath = AssetDatabase.GUIDToAssetPath(scriptGuid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs"); var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length); using (var writer = new StreamWriter(absolutePath)) @@ -73,43 +118,75 @@ namespace Fungus.EditorUtils writer.WriteLine(""); writer.WriteLine("namespace Fungus.EditorUtils"); writer.WriteLine("{"); - writer.WriteLine(" internal static partial class FungusEditorResources"); + writer.WriteLine(" internal partial class FungusEditorResources : ScriptableObject"); writer.WriteLine(" {"); - writer.WriteLine(" private static readonly string[] resourceNames = new [] {"); - foreach (var pair in textures) + foreach (var name in textureNames) { - writer.WriteLine(" \"" + pair.Key + "\","); + writer.WriteLine(" [SerializeField] private EditorTexture " + name + ";"); } - writer.WriteLine(" };"); writer.WriteLine(""); - foreach (var pair in textures) + foreach (var name in textureNames) { - var name = pair.Key; var pascalCase = string.Join("", name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select( s => s.Substring(0, 1).ToUpper() + s.Substring(1)).ToArray() ); - writer.WriteLine(" public static Texture2D " + pascalCase + " { get { return GetTexture(\"" + name + "\"); } }"); + writer.WriteLine(" public static Texture2D " + pascalCase + " { get { return Instance." + name + ".Texture2D; } }"); } writer.WriteLine(" }"); writer.WriteLine("}"); } + Instance.updateOnReloadScripts = true; AssetDatabase.ImportAsset(relativePath); } - private static Texture2D GetTexture(string name) + [DidReloadScripts] + private static void OnDidReloadScripts() { - Texture2D texture; - if (!textures.TryGetValue(name, out texture)) + if (Instance.updateOnReloadScripts) + { + UpdateTextureReferences(Instance); + } + } + + private static void UpdateTextureReferences(FungusEditorResources instance) + { + // Iterate through all fields in class and set texture references + var serializedObject = new SerializedObject(instance); + var prop = serializedObject.GetIterator(); + var rootFolder = new [] { GetRootFolder() }; + + prop.NextVisible(true); + while (prop.NextVisible(false)) { - Debug.LogWarning("Texture \"" + name + "\" not found!"); + if (prop.propertyType == SerializedPropertyType.Generic) + { + var guids = AssetDatabase.FindAssets(prop.name + " t:Texture2D", rootFolder); + var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).Where( + path => path.Contains(prop.name + ".") + ); + + foreach (var path in paths) + { + var texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D; + if (path.ToLower().Contains("/pro/")) + { + prop.FindPropertyRelative("pro").objectReferenceValue = texture; + } + else + { + prop.FindPropertyRelative("free").objectReferenceValue = texture; + } + } + } } - - return texture; + + instance.updateOnReloadScripts = false; + serializedObject.ApplyModifiedPropertiesWithoutUndo(); } } } diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs index e2eab920..27b06e77 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -5,40 +5,38 @@ using UnityEngine; namespace Fungus.EditorUtils { - internal static partial class FungusEditorResources + internal partial class FungusEditorResources : ScriptableObject { - private static readonly string[] resourceNames = new [] { - "add", - "add_small", - "delete", - "down", - "duplicate", - "up", - "choice_node_off", - "choice_node_on", - "command_background", - "event_node_off", - "event_node_on", - "play_big", - "play_small", - "process_node_off", - "process_node_on", - }; + [SerializeField] private EditorTexture add; + [SerializeField] private EditorTexture add_small; + [SerializeField] private EditorTexture delete; + [SerializeField] private EditorTexture down; + [SerializeField] private EditorTexture duplicate; + [SerializeField] private EditorTexture up; + [SerializeField] private EditorTexture choice_node_off; + [SerializeField] private EditorTexture choice_node_on; + [SerializeField] private EditorTexture command_background; + [SerializeField] private EditorTexture event_node_off; + [SerializeField] private EditorTexture event_node_on; + [SerializeField] private EditorTexture play_big; + [SerializeField] private EditorTexture play_small; + [SerializeField] private EditorTexture process_node_off; + [SerializeField] private EditorTexture process_node_on; - public static Texture2D Add { get { return GetTexture("add"); } } - public static Texture2D AddSmall { get { return GetTexture("add_small"); } } - public static Texture2D Delete { get { return GetTexture("delete"); } } - public static Texture2D Down { get { return GetTexture("down"); } } - public static Texture2D Duplicate { get { return GetTexture("duplicate"); } } - public static Texture2D Up { get { return GetTexture("up"); } } - public static Texture2D ChoiceNodeOff { get { return GetTexture("choice_node_off"); } } - public static Texture2D ChoiceNodeOn { get { return GetTexture("choice_node_on"); } } - public static Texture2D CommandBackground { get { return GetTexture("command_background"); } } - public static Texture2D EventNodeOff { get { return GetTexture("event_node_off"); } } - public static Texture2D EventNodeOn { get { return GetTexture("event_node_on"); } } - public static Texture2D PlayBig { get { return GetTexture("play_big"); } } - public static Texture2D PlaySmall { get { return GetTexture("play_small"); } } - public static Texture2D ProcessNodeOff { get { return GetTexture("process_node_off"); } } - public static Texture2D ProcessNodeOn { get { return GetTexture("process_node_on"); } } + public static Texture2D Add { get { return Instance.add.Texture2D; } } + public static Texture2D AddSmall { get { return Instance.add_small.Texture2D; } } + public static Texture2D Delete { get { return Instance.delete.Texture2D; } } + public static Texture2D Down { get { return Instance.down.Texture2D; } } + public static Texture2D Duplicate { get { return Instance.duplicate.Texture2D; } } + public static Texture2D Up { get { return Instance.up.Texture2D; } } + public static Texture2D ChoiceNodeOff { get { return Instance.choice_node_off.Texture2D; } } + public static Texture2D ChoiceNodeOn { get { return Instance.choice_node_on.Texture2D; } } + public static Texture2D CommandBackground { get { return Instance.command_background.Texture2D; } } + public static Texture2D EventNodeOff { get { return Instance.event_node_off.Texture2D; } } + public static Texture2D EventNodeOn { get { return Instance.event_node_on.Texture2D; } } + public static Texture2D PlayBig { get { return Instance.play_big.Texture2D; } } + public static Texture2D PlaySmall { get { return Instance.play_small.Texture2D; } } + public static Texture2D ProcessNodeOff { get { return Instance.process_node_off.Texture2D; } } + public static Texture2D ProcessNodeOn { get { return Instance.process_node_on.Texture2D; } } } } From 8be8b378c26451375e0f903f4c8d6075eaabde62 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Sat, 12 Nov 2016 14:08:58 -0800 Subject: [PATCH 14/22] Fixed compatibility with Unity 5.0 and 5.1 and handled reimporting resources asset --- .../Scripts/Editor/FungusEditorResources.cs | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index 109c3dda..ca9c2c21 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -8,6 +8,9 @@ using System; using System.IO; using System.Linq; using System.Collections.Generic; +#if UNITY_5_0 || UNITY_5_1 +using System.Reflection; +#endif namespace Fungus.EditorUtils { @@ -32,6 +35,26 @@ namespace Fungus.EditorUtils } } + internal class EditorResourcesPostProcessor : AssetPostprocessor + { + private static void OnPostprocessAllAssets(string[] importedAssets, string[] _, string[] __, string[] ___) + { + foreach (var path in importedAssets) + { + if (path.EndsWith("FungusEditorResources.asset")) + { + var asset = AssetDatabase.LoadAssetAtPath(path, typeof(FungusEditorResources)) as FungusEditorResources; + if (asset != null) + { + FungusEditorResources.UpdateTextureReferences(asset); + AssetDatabase.SaveAssets(); + return; + } + } + } + } + } + internal partial class FungusEditorResources : ScriptableObject { [Serializable] @@ -68,8 +91,6 @@ namespace Fungus.EditorUtils { instance = ScriptableObject.CreateInstance(typeof(FungusEditorResources)) as FungusEditorResources; AssetDatabase.CreateAsset(instance, GetRootFolder() + "/FungusEditorResources.asset"); - UpdateTextureReferences(instance); - AssetDatabase.SaveAssets(); } else { @@ -153,9 +174,9 @@ namespace Fungus.EditorUtils } } - private static void UpdateTextureReferences(FungusEditorResources instance) + internal static void UpdateTextureReferences(FungusEditorResources instance) { - // Iterate through all fields in class and set texture references + // Iterate through all fields in instance and set texture references var serializedObject = new SerializedObject(instance); var prop = serializedObject.GetIterator(); var rootFolder = new [] { GetRootFolder() }; @@ -186,7 +207,15 @@ namespace Fungus.EditorUtils } instance.updateOnReloadScripts = false; + + // The ApplyModifiedPropertiesWithoutUndo() function wasn't documented until Unity 5.2 +#if UNITY_5_0 || UNITY_5_1 + var flags = BindingFlags.Instance | BindingFlags.NonPublic; + var applyMethod = typeof(SerializedObject).GetMethod("ApplyModifiedPropertiesWithoutUndo", flags); + applyMethod.Invoke(serializedObject, null); +#else serializedObject.ApplyModifiedPropertiesWithoutUndo(); +#endif } } } From dd5bdf6dcf7c396ec23ac441a1c7044472677bad Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Sat, 12 Nov 2016 17:12:54 -0800 Subject: [PATCH 15/22] Reimplemented cut/copy/paste using SerializedObjects -Added cut/copy/paste functionality -Replaced DuplicateBlocks() functions with calls to Copy() and Paste() to reduce duplicated code --- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 245 +++++++++++++----- 1 file changed, 177 insertions(+), 68 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index 9c49352f..9a631d1f 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -8,11 +8,94 @@ using System; using System.Linq; using System.Collections.Generic; using System.Reflection; +using Object = UnityEngine.Object; namespace Fungus.EditorUtils { public class FlowchartWindow : EditorWindow { + protected class ClipboardObject + { + internal SerializedObject serializedObject; + internal Type type; + + internal ClipboardObject(Object obj) + { + serializedObject = new SerializedObject(obj); + type = obj.GetType(); + } + } + + protected class BlockCopy + { + private SerializedObject block = null; + private List commands = new List(); + private ClipboardObject eventHandler = null; + + internal BlockCopy(Block block) + { + this.block = new SerializedObject(block); + foreach (var command in block.CommandList) + { + commands.Add(new ClipboardObject(command)); + } + if (block._EventHandler != null) + { + eventHandler = new ClipboardObject(block._EventHandler); + } + } + + private void CopyProperties(SerializedObject source, Object dest, params SerializedPropertyType[] excludeTypes) + { + var newSerializedObject = new SerializedObject(dest); + var prop = source.GetIterator(); + while (prop.NextVisible(true)) + { + if (!excludeTypes.Contains(prop.propertyType)) + { + newSerializedObject.CopyFromSerializedProperty(prop); + } + } + + newSerializedObject.ApplyModifiedProperties(); + } + + internal Block PasteBlock(Flowchart flowchart) + { + var newBlock = FlowchartWindow.CreateBlock(flowchart, Vector2.zero); + + // Copy all command serialized properties + // Copy references to match duplication behavior + foreach (var command in commands) + { + var newCommand = Undo.AddComponent(flowchart.gameObject, command.type) as Command; + CopyProperties(command.serializedObject, newCommand); + newBlock.CommandList.Add(newCommand); + } + + // Copy event handler + if (eventHandler != null) + { + var newEventHandler = Undo.AddComponent(flowchart.gameObject, eventHandler.type) as EventHandler; + CopyProperties(eventHandler.serializedObject, newEventHandler); + newBlock._EventHandler = newEventHandler; + } + + // Copy block properties, but do not copy references because those were just assigned + CopyProperties( + block, + newBlock, + SerializedPropertyType.ObjectReference, + SerializedPropertyType.Generic, + SerializedPropertyType.ArraySize + ); + + newBlock.BlockName = flowchart.GetUniqueBlockKey(block.FindProperty("blockName").stringValue + " (Copy)"); + + return newBlock; + } + } + public static List deleteList = new List(); protected List windowBlockMap = new List(); @@ -39,6 +122,8 @@ namespace Fungus.EditorUtils protected Vector2 startSelectionBoxPosition = -Vector2.one; protected List mouseDownSelectionState = new List(); + protected List copyList = new List(); + // Context Click occurs on MouseDown which interferes with panning // Track right click positions manually to show menus on MouseUp protected Vector2 rightClickDown = -Vector2.one; @@ -66,6 +151,7 @@ namespace Fungus.EditorUtils nodeStyle.wordWrap = true; addTexture = Resources.Load("Icons/add_small") as Texture2D; + copyList.Clear(); } protected virtual void OnInspectorUpdate() @@ -155,6 +241,11 @@ namespace Fungus.EditorUtils { Undo.DestroyObjectImmediate(command); } + + if (deleteBlock._EventHandler != null) + { + Undo.DestroyObjectImmediate(deleteBlock._EventHandler); + } Undo.DestroyObjectImmediate((Block)deleteBlock); flowchart.ClearSelectedCommands(); @@ -512,14 +603,26 @@ namespace Fungus.EditorUtils // Use a copy because flowchart.SelectedBlocks gets modified var blockList = new List(flowchart.SelectedBlocks); - menu.AddItem(new GUIContent ("Duplicate"), false, DuplicateBlocks, blockList); + menu.AddItem(new GUIContent ("Copy"), false, () => Copy(flowchart)); + menu.AddItem(new GUIContent ("Cut"), false, () => Cut(flowchart)); + menu.AddItem(new GUIContent ("Duplicate"), false, () => Duplicate(flowchart)); menu.AddItem(new GUIContent ("Delete"), false, DeleteBlocks, blockList); } // Clicked on empty space in grid else { DeselectAll(flowchart); + menu.AddItem(new GUIContent("Add Block"), false, () => CreateBlock(flowchart, mousePosition / flowchart.Zoom - flowchart.ScrollPos)); + + if (copyList.Count > 0) + { + menu.AddItem(new GUIContent("Paste"), false, () => Paste(flowchart, mousePosition)); + } + else + { + menu.AddDisabledItem(new GUIContent("Paste")); + } } var menuRect = new Rect(); @@ -1042,71 +1145,6 @@ namespace Fungus.EditorUtils blocks.ForEach(block => FlowchartWindow.deleteList.Add(block)); } - protected static void DuplicateBlocks(object obj) - { - DuplicateBlocks(obj, new Vector2(20, 0)); - } - - protected static void DuplicateBlocks(object obj, Vector2 offset) - { - var flowchart = GetFlowchart(); - - Undo.RecordObject(flowchart, "Select"); - flowchart.ClearSelectedBlocks(); - - var blocks = obj as List; - - foreach (var block in blocks) - { - Vector2 newPosition = block._NodeRect.position + offset; - - Block oldBlock = block; - - Block newBlock = FlowchartWindow.CreateBlock(flowchart, newPosition); - newBlock.BlockName = flowchart.GetUniqueBlockKey(oldBlock.BlockName + " (Copy)"); - - Undo.RecordObject(newBlock, "Duplicate Block"); - - var commandList = oldBlock.CommandList; - foreach (var command in commandList) - { - if (ComponentUtility.CopyComponent(command)) - { - if (ComponentUtility.PasteComponentAsNew(flowchart.gameObject)) - { - Command[] commands = flowchart.GetComponents(); - Command pastedCommand = commands.Last(); - if (pastedCommand != null) - { - pastedCommand.ItemId = flowchart.NextItemId(); - newBlock.CommandList.Add(pastedCommand); - } - } - - // This stops the user pasting the command manually into another game object. - ComponentUtility.CopyComponent(flowchart.transform); - } - } - - if (oldBlock._EventHandler != null) - { - if (ComponentUtility.CopyComponent(oldBlock._EventHandler)) - { - if (ComponentUtility.PasteComponentAsNew(flowchart.gameObject)) - { - EventHandler[] eventHandlers = flowchart.GetComponents(); - EventHandler pastedEventHandler = eventHandlers.Last(); - if (pastedEventHandler != null) - { - pastedEventHandler.ParentBlock = newBlock; - newBlock._EventHandler = pastedEventHandler; - } - } - } - } - } - } - protected static void ShowBlockInspector(Flowchart flowchart) { if (blockInspector == null) @@ -1149,18 +1187,74 @@ namespace Fungus.EditorUtils return Event.current.shift || EditorGUI.actionKey; } + protected virtual void Copy(Flowchart flowchart) + { + copyList.Clear(); + + foreach (var block in flowchart.SelectedBlocks) + { + copyList.Add(new BlockCopy(block)); + } + } + + protected virtual void Cut(Flowchart flowchart) + { + Copy(flowchart); + Undo.RecordObject(flowchart, "Cut"); + DeleteBlocks(flowchart.SelectedBlocks); + } + + // Center is position in unscaled window space + protected virtual void Paste(Flowchart flowchart, Vector2 center, bool relative = false) + { + Undo.RecordObject(flowchart, "Deselect"); + DeselectAll(flowchart); + + var pasteList = new List(); + + foreach (var copy in copyList) + { + pasteList.Add(copy.PasteBlock(flowchart)); + } + + var copiedCenter = GetBlockCenter(flowchart, pasteList.ToArray()) + flowchart.ScrollPos; + var delta = relative ? center : (center / flowchart.Zoom - copiedCenter); + + foreach (var block in pasteList) + { + var tempRect = block._NodeRect; + tempRect.position += delta; + block._NodeRect = tempRect; + } + } + + protected virtual void Duplicate(Flowchart flowchart) + { + var tempCopyList = new List(copyList); + Copy(flowchart); + Paste(flowchart, new Vector2(20, 0), true); + copyList = tempCopyList; + } + protected virtual void ValidateCommands(Flowchart flowchart) { if (Event.current.type == EventType.ValidateCommand) { var c = Event.current.commandName; - if (c == "Delete" || c == "Duplicate") + if (c == "Copy" || c == "Cut" || c == "Delete" || c == "Duplicate") { if (flowchart.SelectedBlocks.Count > 0) { Event.current.Use(); } } + else if (c == "Paste") + { + if (copyList.Count > 0) + { + Event.current.Use(); + } + } else if (c == "SelectAll") { Event.current.Use(); @@ -1174,13 +1268,28 @@ namespace Fungus.EditorUtils { switch (Event.current.commandName) { + case "Copy": + Copy(flowchart); + Event.current.Use(); + break; + + case "Cut": + Cut(flowchart); + Event.current.Use(); + break; + + case "Paste": + Paste(flowchart, position.center - position.position); + Event.current.Use(); + break; + case "Delete": DeleteBlocks(flowchart.SelectedBlocks); Event.current.Use(); break; case "Duplicate": - DuplicateBlocks(new List(flowchart.SelectedBlocks)); + Duplicate(flowchart); Event.current.Use(); break; From bb0aa56ad08b5c30e38500c2ac840c68c492fade Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Sat, 12 Nov 2016 17:46:56 -0800 Subject: [PATCH 16/22] Updated paste function to assign command ItemIds and event handler parent blocks --- Assets/Fungus/Scripts/Editor/FlowchartWindow.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index b89e197b..761ddc9d 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -3,7 +3,6 @@ using UnityEngine; using UnityEditor; -using UnityEditorInternal; using System; using System.Linq; using System.Collections.Generic; @@ -70,6 +69,7 @@ namespace Fungus.EditorUtils { var newCommand = Undo.AddComponent(flowchart.gameObject, command.type) as Command; CopyProperties(command.serializedObject, newCommand); + newCommand.ItemId = flowchart.NextItemId(); newBlock.CommandList.Add(newCommand); } @@ -78,6 +78,7 @@ namespace Fungus.EditorUtils { var newEventHandler = Undo.AddComponent(flowchart.gameObject, eventHandler.type) as EventHandler; CopyProperties(eventHandler.serializedObject, newEventHandler); + newEventHandler.ParentBlock = newBlock; newBlock._EventHandler = newEventHandler; } From 88ffa62c3f51d095e23352d09583d0b35e71e257 Mon Sep 17 00:00:00 2001 From: Zach Vinless Date: Wed, 16 Nov 2016 22:40:57 -0800 Subject: [PATCH 17/22] Added connection_point to FungusEditorResources asset --- Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta | 10 +++++++++- .../Fungus/EditorResources/FungusEditorResources.asset | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta b/Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta index f6ebfb64..5244b496 100644 --- a/Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta +++ b/Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta @@ -7,8 +7,16 @@ PluginImporter: isPreloaded: 0 platformData: Any: - enabled: 1 + enabled: 0 settings: {} + Editor: + enabled: 1 + settings: + DefaultValueInitialized: true + WindowsStoreApps: + enabled: 0 + settings: + CPU: AnyCPU userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Fungus/EditorResources/FungusEditorResources.asset b/Assets/Fungus/EditorResources/FungusEditorResources.asset index f8d40f35..594b27ed 100644 --- a/Assets/Fungus/EditorResources/FungusEditorResources.asset +++ b/Assets/Fungus/EditorResources/FungusEditorResources.asset @@ -39,6 +39,9 @@ MonoBehaviour: command_background: free: {fileID: 2800000, guid: a5c9a4271b3de4e4f86eff7f8a1bd768, type: 3} pro: {fileID: 0} + connection_point: + free: {fileID: 2800000, guid: f08a4c27d7efe4aa6a35348a4e8aec8f, type: 3} + pro: {fileID: 0} event_node_off: free: {fileID: 2800000, guid: 0e16a209826864df7b05f6d3901aae7a, type: 3} pro: {fileID: 0} From 6f2ec7fb5f94e183f716a5195065574b22e4c806 Mon Sep 17 00:00:00 2001 From: zvinless Date: Sun, 20 Nov 2016 22:52:20 -0800 Subject: [PATCH 18/22] Added simple search filter to highlight blocks --- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index f7d3b90b..b6bbadde 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -131,7 +131,10 @@ namespace Fungus.EditorUtils // Context Click occurs on MouseDown which interferes with panning // Track right click positions manually to show menus on MouseUp protected Vector2 rightClickDown = -Vector2.one; - protected readonly float rightClickTolerance = 5f; + protected const float rightClickTolerance = 5f; + + protected string searchString = string.Empty; + protected const string searchFieldName = "search"; [MenuItem("Tools/Fungus/Flowchart Window")] static void Init() @@ -268,6 +271,25 @@ namespace Fungus.EditorUtils } deleteList.Clear(); + // Clear search filter focus + if (Event.current.type == EventType.MouseDown) + { + GUIUtility.keyboardControl = 0; + } + + if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) + { + if (GUI.GetNameOfFocusedControl() == searchFieldName) + { + searchString = string.Empty; + GUIUtility.keyboardControl = 0; + } + else if (flowchart.SelectedBlocks.Count > 0) + { + DeselectAll(flowchart); + } + } + DrawFlowchartView(flowchart); DrawOverlay(flowchart); @@ -318,6 +340,15 @@ namespace Fungus.EditorUtils GUILayout.FlexibleSpace(); + GUI.SetNextControlName(searchFieldName); + searchString = EditorGUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSeachTextField"), GUILayout.Width(150)); + + if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) // These are spelled correctly + { + searchString = string.Empty; + GUIUtility.keyboardControl = 0; + } + GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); @@ -1016,6 +1047,11 @@ namespace Fungus.EditorUtils var brightness = tintColor.r * 0.3 + tintColor.g * 0.59 + tintColor.b * 0.11; nodeStyleCopy.normal.textColor = brightness >= 0.5 ? Color.black : Color.white; + if (searchString != string.Empty && !block.BlockName.ToLower().Contains(searchString.ToLower())) + { + tintColor.a *= 0.2f; + } + nodeStyleCopy.normal.background = offTex; GUI.backgroundColor = tintColor; GUI.Box(boxRect, block.BlockName, nodeStyleCopy); @@ -1293,7 +1329,7 @@ namespace Fungus.EditorUtils Event.current.Use(); } } - else if (c == "SelectAll") + else if (c == "SelectAll" || c == "Find") { Event.current.Use(); } @@ -1340,6 +1376,10 @@ namespace Fungus.EditorUtils } Event.current.Use(); break; + case "Find": + EditorGUI.FocusTextInControl(searchFieldName); + Event.current.Use(); + break; } } } From 4ca7ecbdc647ab8c58353466875e1952943a6fb9 Mon Sep 17 00:00:00 2001 From: zvinless Date: Wed, 23 Nov 2016 22:22:13 -0800 Subject: [PATCH 19/22] Added block search dropdown Added popup window that appears beneath search filter so that users can easily find blocks by name --- .../FungusEditorResources.asset | 3 + .../EditorResources/Textures/bullet_point.png | Bin 0 -> 3071 bytes .../Textures/bullet_point.png.meta | 55 +++ .../Fungus/Scripts/Editor/FlowchartWindow.cs | 312 ++++++++++++++---- .../Editor/FungusEditorResourcesGenerated.cs | 2 + 5 files changed, 311 insertions(+), 61 deletions(-) create mode 100644 Assets/Fungus/EditorResources/Textures/bullet_point.png create mode 100644 Assets/Fungus/EditorResources/Textures/bullet_point.png.meta diff --git a/Assets/Fungus/EditorResources/FungusEditorResources.asset b/Assets/Fungus/EditorResources/FungusEditorResources.asset index 594b27ed..05ea3abc 100644 --- a/Assets/Fungus/EditorResources/FungusEditorResources.asset +++ b/Assets/Fungus/EditorResources/FungusEditorResources.asset @@ -30,6 +30,9 @@ MonoBehaviour: up: free: {fileID: 2800000, guid: 8f1242ad894201f43b2b6d52fd990f77, type: 3} pro: {fileID: 2800000, guid: 2a76a781db2994b33b83cd84b8835da7, type: 3} + bullet_point: + free: {fileID: 2800000, guid: 4ef739c68bb234717a60a2bb83ff8602, type: 3} + pro: {fileID: 0} choice_node_off: free: {fileID: 2800000, guid: 7b6fc04aac74540e39e9502da5312ce7, type: 3} pro: {fileID: 0} diff --git a/Assets/Fungus/EditorResources/Textures/bullet_point.png b/Assets/Fungus/EditorResources/Textures/bullet_point.png new file mode 100644 index 0000000000000000000000000000000000000000..bcafc7337b26c8cfccda88c688f191cd1960ef17 GIT binary patch literal 3071 zcmVjeH zXlY1#a%EF`PE=!hYhyWNB0oL~Ja{^IZE$U6bYUQPZES9HI(R)IVPtP&WjbziI&Eci zVJ{*ecsh7(aCB=uB3MmOAVY6*Wgs;!H7+nBJ_;Z_a%5&YQba}|cx`NMb2@TlW<4Tk zbaZe!FE4j@cP@7`E^l&YFEKeeIWI6WFETPMa%5&Lb9rubVR$WWb0Z=?3Lqdna%5&Y zL}hbha%pgMX>V>Ia%5&YVPbD}bUh*>FFpz&JTG!&W;#+tMm`EWFL*k5ZE$U6bYVUU zJU@7FVPk7$bRcDJWIZBsB0oMFN~`Js016#xLqkwzE^KvpAaHVTW@&6?002mdt(JFG z6xSZd@67f_TUa_Qy-9BiNbgO06_sUyrLM445fzbO1R{!v2q=Pts$ewKSP)Sxh=2kX zG>ZfQc}-v4g01i`)~cj{_4+U zvj5_>XZcbBky=PodIEQAWOQ7_H_rqXi2AIg22t;v14%^jlW3A;I z+Lx{n?dDf4u^RxBJVa!F)tCwZbUp)sy7*O7c#YUO0KkPoRth(DO+&AqFvwTO4}^g@ zkO2xn6=(uIU!=-RFd9LKXic;k+6nE4W}y?&JJAK`GITw<4c&{ri=IHwqd#LP z7%7Yf#uVd>3B<55X_#D038og)in)pz!AxNmu~;k(tAaJgI$?vbG1%?c0_-tt3$`0O zgq_4L;BYu`oCeMu=YeD5l5x4XqqtMJOSoa&6z(0KgqOwZ;T`b7cn&@rUxIJMU&IgN zr}4`K0fG|2l;A-KCu}1W5^4xtggb;O!ZJ~is6sR+`VwP^yNRX5X5v-iIPndMM3N_& zki1CIq%2Y?=?v*QX@c~gEJRi(+mb`bDdhd+I&wGp0r?GuLQ$qzQGzMSl>L+j$`#5J z$~!(PpBA4pUpU_`zH+`czG1$X`~-d_erx{C{2BZu{O9=Z@XrYl1e67A1(*Um1@K|UBXKuP2#x3Rf#!CVM#Md zmSmpfS;>b|u#~!#x72p2lT!Us3(_*uj?xLzN2RYw&&kkatYl(jie)a!%*s+_Eo7r* zi)Am#KBtS&t?6;}QhG0aUQSBRNiIdMN^U@ISzblnPd;0|MgFk@QGuZlsZgxYqcE>1 ztLUznso13WP>G<#P>NDIqSU9fq^zPGpuAVPU3o@DOvPCxL#0V&T$Q3~shX%-t$I%l ztHw}^RXe6Os1B3jCtZA*8s@bGDp+(bj z)5_Lr*Lta~s2!|*P`gk2vyP!ooKB6-BV8d~7u{^#F5TC9>Uu1_a=m-{6nzK%UHTpR zuM9K{A`Ffj+&82ex*P5_>@oagWNgGWYBriRRx}PZt}q^B2s1nx1&r$^7!wnF|S&6(y^<~$3!MX1FI3!bH%CDXFn@~M@A zRk&5H)wH#mb&T~X>z6hu4Gpq*D}|qZt8Aaw=Q?s-NpTo`}hW> z4V(?_9>BxdVZgeQkUTeINO$`la~w z`1AXR_&4}31=s}?1@Hp319t@83X%wl4(bTT1^Wlr1}|*1-*|ZARES|nZpi2+l}+iJ zZfus=9Jl$x7XB^FE$2cpp#hBb}3#Gx?q4cTKr`x!l~by=HqWzej%`{r$i`{e4IGea;KdyP2<( zUy}c^fK_nw2i+e^e^}WcxqqP0sPOm!>;cY!(Sw!;>x%@7GKwY-xgTmPrWfZGzdgL= z@Qo6KlFB2*BPmCCrEaAiM-`7AIQp?Hs%)g(ro5#>s$yTo(y{Pk!^f?TH&;qm=2w0= z5q;u*m19*~wQ_aIN$knglh11WYx;g<{Mb+{QJY`;sg6^}tM{(&Z7^VobTNl*)TFR>Nk3SEM$y#Km7j8gSZE;9;QBAev~zi z8P9tx@VMlO)RXF8)qZW^8SySm*iH05^?CYek~R6_x1`@bPUSqKJS&-&oo<-Xn>j!0 zFgy5si7Qn!1<|H+*d2F3*Lyose5biwr9a};mKnB z;__17JMnk*?-}p=J_LN2UQYXn`&jx(?Nirh*U#fC@hd9{OfK_F6hI*Zj*JB0bsYed zAS62sBKeAMEyw+lXP|GA&7Tae1%Bnc{I#t2rHlZmvjV^`3jjAHqZ~(u62fF;UX7i; zRsh!5|7-kFNs;<`YkQEnNHlr3vhqe609+RUpSUY4%g0t$KGh&*9{|vu_&>e<2d`z! z)xsjl`-J=|-B#H9j|}&32id~payW{k00009a7bBm000XU000XU0RWnu7ytkOVM# copyList = new List(); public static List deleteList = new List(); @@ -133,9 +140,15 @@ namespace Fungus.EditorUtils protected Vector2 rightClickDown = -Vector2.one; protected const float rightClickTolerance = 5f; - protected string searchString = string.Empty; protected const string searchFieldName = "search"; - + private string searchString = string.Empty; + protected Rect searchRect; + protected Rect popupRect; + protected Block[] filteredBlocks; + protected int blockPopupSelection = -1; + protected Vector2 popupScroll; + protected bool mouseOverPopup; + [MenuItem("Tools/Fungus/Flowchart Window")] static void Init() { @@ -162,6 +175,8 @@ namespace Fungus.EditorUtils gridLineColor.a = EditorGUIUtility.isProSkin ? 0.5f : 0.25f; copyList.Clear(); + + wantsMouseMove = true; // For hover selection in block search popup } protected virtual void OnInspectorUpdate() @@ -272,21 +287,18 @@ namespace Fungus.EditorUtils deleteList.Clear(); // Clear search filter focus - if (Event.current.type == EventType.MouseDown) + if (Event.current.type == EventType.MouseDown && !searchRect.Contains(Event.current.mousePosition) && + !popupRect.Contains(Event.current.mousePosition)) { - GUIUtility.keyboardControl = 0; + CloseBlockPopup(); } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { - if (GUI.GetNameOfFocusedControl() == searchFieldName) - { - searchString = string.Empty; - GUIUtility.keyboardControl = 0; - } - else if (flowchart.SelectedBlocks.Count > 0) + if (GUI.GetNameOfFocusedControl() != searchFieldName && flowchart.SelectedBlocks.Count > 0) { DeselectAll(flowchart); + Event.current.Use(); } } @@ -340,13 +352,95 @@ namespace Fungus.EditorUtils GUILayout.FlexibleSpace(); + var blocks = flowchart.GetComponents(); + + // Intercept mouse and keyboard events before search field uses them + if (GUI.GetNameOfFocusedControl() == searchFieldName) + { + if (Event.current.type == EventType.KeyDown) + { + var centerBlock = false; + var selectBlock = false; + var closePopup = false; + var useEvent = false; + + switch (Event.current.keyCode) + { + case KeyCode.DownArrow: + ++blockPopupSelection; + centerBlock = true; + useEvent = true; + break; + case KeyCode.UpArrow: + --blockPopupSelection; + centerBlock = true; + useEvent = true; + break; + case KeyCode.Return: + centerBlock = true; + selectBlock = true; + closePopup = true; + useEvent = true; + break; + case KeyCode.Escape: + closePopup = true; + useEvent = true; + break; + } + + blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Length - 1); + + if (centerBlock && filteredBlocks.Length > 0) + { + var block = filteredBlocks[blockPopupSelection]; + CenterBlock(flowchart, block); + + if (selectBlock) + { + SelectBlock(flowchart, block); + } + } + + if (closePopup) + { + CloseBlockPopup(); + } + + if (useEvent) + { + Event.current.Use(); + } + } + } + else if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && + searchRect.Contains(Event.current.mousePosition)) + { + blockPopupSelection = 0; + } + GUI.SetNextControlName(searchFieldName); - searchString = EditorGUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSeachTextField"), GUILayout.Width(150)); + var newString = EditorGUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSeachTextField"), GUILayout.Width(150)); + if (newString != searchString) + { + searchString = newString; + } + + // Update this every frame in case of redo/undo while popup is open + filteredBlocks = blocks.Where(block => block.BlockName.ToLower().Contains(searchString.ToLower())).ToArray(); + blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Length - 1); + + if (Event.current.type == EventType.Repaint) + { + searchRect = GUILayoutUtility.GetLastRect(); + popupRect = searchRect; + popupRect.width += 12; + popupRect.y += popupRect.height; + popupRect.height = Mathf.Min(filteredBlocks.Length * 16, position.height - 22); + } - if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) // These are spelled correctly + if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) { - searchString = string.Empty; - GUIUtility.keyboardControl = 0; + CloseBlockPopup(); } GUILayout.EndHorizontal(); @@ -396,7 +490,9 @@ namespace Fungus.EditorUtils if (Event.current.type == EventType.Repaint) { Rect toolbarRect = new Rect(0, 0, position.width, 18); - mouseOverVariables = variableWindowRect.Contains(Event.current.mousePosition) || toolbarRect.Contains(rawMousePosition); + mouseOverPopup = (GUI.GetNameOfFocusedControl() == searchFieldName && popupRect.Contains(rawMousePosition)); + mouseOverVariables = variableWindowRect.Contains(Event.current.mousePosition) || + toolbarRect.Contains(rawMousePosition) || mouseOverPopup; } GUILayout.EndScrollView(); @@ -406,6 +502,75 @@ namespace Fungus.EditorUtils GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); + + // Draw block search popup on top of other controls + if (GUI.GetNameOfFocusedControl() == searchFieldName && filteredBlocks.Length > 0) + { + DrawBlockPopup(flowchart); + } + } + + protected virtual void DrawBlockPopup(Flowchart flowchart) + { + blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Length - 1); + + GUI.Box(popupRect, "", GUI.skin.FindStyle("sv_iconselector_back")); + + if (Event.current.type == EventType.MouseMove) + { + if (popupRect.Contains(Event.current.mousePosition)) + { + var relativeY = Event.current.mousePosition.y - popupRect.yMin + popupScroll.y; + blockPopupSelection = (int) (relativeY / 16); + } + + Event.current.Use(); + } + + GUILayout.BeginArea(popupRect); + popupScroll = EditorGUILayout.BeginScrollView(popupScroll, GUIStyle.none, GUI.skin.verticalScrollbar); + + var normalStyle = new GUIStyle(GUI.skin.FindStyle("MenuItem")); + normalStyle.padding = new RectOffset(8, 0, 0, 0); + normalStyle.imagePosition = ImagePosition.ImageLeft; + var selectedStyle = new GUIStyle(normalStyle); + selectedStyle.normal = selectedStyle.hover; + normalStyle.hover = normalStyle.normal; + + for (int i = 0; i < filteredBlocks.Length; ++i) + { + EditorGUILayout.BeginHorizontal(GUILayout.Height(16)); + + var block = filteredBlocks[i]; + var style = i == blockPopupSelection ? selectedStyle : normalStyle; + + GUI.contentColor = GetBlockGraphics(block).tint; + + var buttonPressed = false; + if (GUILayout.Button(FungusEditorResources.BulletPoint, style, GUILayout.Width(16))) + { + buttonPressed = true; + } + + GUI.contentColor = Color.white; + + if (GUILayout.Button(block.BlockName, style)) + { + buttonPressed = true; + } + + if (buttonPressed) + { + CenterBlock(flowchart, block); + SelectBlock(flowchart, block); + CloseBlockPopup(); + } + + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.EndScrollView(); + GUILayout.EndArea(); } protected virtual void DrawFlowchartView(Flowchart flowchart) @@ -828,7 +993,7 @@ namespace Fungus.EditorUtils bool zoom = false; // Scroll wheel - if (Event.current.type == EventType.ScrollWheel) + if (Event.current.type == EventType.ScrollWheel && !mouseOverPopup) { zoom = true; } @@ -986,44 +1151,7 @@ namespace Fungus.EditorUtils } GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle); - Texture2D offTex; - Texture2D onTex; - Color defaultColor; - - if (block._EventHandler != null) - { - offTex = FungusEditorResources.EventNodeOff; - onTex = FungusEditorResources.EventNodeOn; - defaultColor = FungusConstants.DefaultEventBlockTint; - } - else - { - // Count the number of unique connections (excluding self references) - var uniqueList = new List(); - var connectedBlocks = block.GetConnectedBlocks(); - foreach (var connectedBlock in connectedBlocks) - { - if (connectedBlock == block || - uniqueList.Contains(connectedBlock)) - { - continue; - } - uniqueList.Add(connectedBlock); - } - - if (uniqueList.Count > 1) - { - offTex = FungusEditorResources.ChoiceNodeOff; - onTex = FungusEditorResources.ChoiceNodeOn; - defaultColor = FungusConstants.DefaultChoiceBlockTint; - } - else - { - offTex = FungusEditorResources.ProcessNodeOff; - onTex = FungusEditorResources.ProcessNodeOn; - defaultColor = FungusConstants.DefaultProcessBlockTint; - } - } + var graphics = GetBlockGraphics(block); // Make sure node is wide enough to fit the node name text var n = block as Node; @@ -1033,27 +1161,26 @@ namespace Fungus.EditorUtils n._NodeRect = tempRect; Rect boxRect = GUILayoutUtility.GetRect(n._NodeRect.width, n._NodeRect.height); - var tintColor = n.UseCustomTint ? n.Tint : defaultColor; // Draw untinted highlight if (selected) { GUI.backgroundColor = Color.white; - nodeStyleCopy.normal.background = onTex; + nodeStyleCopy.normal.background = graphics.onTexture; GUI.Box(boxRect, "", nodeStyleCopy); } // Draw tinted block; ensure text is readable - var brightness = tintColor.r * 0.3 + tintColor.g * 0.59 + tintColor.b * 0.11; + var brightness = graphics.tint.r * 0.3 + graphics.tint.g * 0.59 + graphics.tint.b * 0.11; nodeStyleCopy.normal.textColor = brightness >= 0.5 ? Color.black : Color.white; - if (searchString != string.Empty && !block.BlockName.ToLower().Contains(searchString.ToLower())) + if (GUI.GetNameOfFocusedControl() == searchFieldName && !filteredBlocks.Contains(block)) { - tintColor.a *= 0.2f; + graphics.tint.a *= 0.2f; } - nodeStyleCopy.normal.background = offTex; - GUI.backgroundColor = tintColor; + nodeStyleCopy.normal.background = graphics.offTexture; + GUI.backgroundColor = graphics.tint; GUI.Box(boxRect, block.BlockName, nodeStyleCopy); GUI.backgroundColor = Color.white; @@ -1376,12 +1503,75 @@ namespace Fungus.EditorUtils } Event.current.Use(); break; + case "Find": + blockPopupSelection = 0; EditorGUI.FocusTextInControl(searchFieldName); Event.current.Use(); break; } } } + + protected virtual void CenterBlock(Flowchart flowchart, Block block) + { + if (flowchart.Zoom < 1) + { + DoZoom(flowchart, 1 - flowchart.Zoom, Vector2.one * 0.5f); + } + + flowchart.ScrollPos = -block._NodeRect.center + position.size * 0.5f / flowchart.Zoom; + } + + protected virtual void CloseBlockPopup() + { + GUIUtility.keyboardControl = 0; + searchString = string.Empty; + } + + protected virtual BlockGraphics GetBlockGraphics(Block block) + { + var graphics = new BlockGraphics(); + + Color defaultTint; + if (block._EventHandler != null) + { + graphics.offTexture = FungusEditorResources.EventNodeOff; + graphics.onTexture = FungusEditorResources.EventNodeOn; + defaultTint = FungusConstants.DefaultEventBlockTint; + } + else + { + // Count the number of unique connections (excluding self references) + var uniqueList = new List(); + var connectedBlocks = block.GetConnectedBlocks(); + foreach (var connectedBlock in connectedBlocks) + { + if (connectedBlock == block || + uniqueList.Contains(connectedBlock)) + { + continue; + } + uniqueList.Add(connectedBlock); + } + + if (uniqueList.Count > 1) + { + graphics.offTexture = FungusEditorResources.ChoiceNodeOff; + graphics.onTexture = FungusEditorResources.ChoiceNodeOn; + defaultTint = FungusConstants.DefaultChoiceBlockTint; + } + else + { + graphics.offTexture = FungusEditorResources.ProcessNodeOff; + graphics.onTexture = FungusEditorResources.ProcessNodeOn; + defaultTint = FungusConstants.DefaultProcessBlockTint; + } + } + + graphics.tint = block.UseCustomTint ? block.Tint : defaultTint; + + return graphics; + } } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs index 7ea1ea0c..f7a0641b 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -13,6 +13,7 @@ namespace Fungus.EditorUtils [SerializeField] private EditorTexture down; [SerializeField] private EditorTexture duplicate; [SerializeField] private EditorTexture up; + [SerializeField] private EditorTexture bullet_point; [SerializeField] private EditorTexture choice_node_off; [SerializeField] private EditorTexture choice_node_on; [SerializeField] private EditorTexture command_background; @@ -30,6 +31,7 @@ namespace Fungus.EditorUtils public static Texture2D Down { get { return Instance.down.Texture2D; } } public static Texture2D Duplicate { get { return Instance.duplicate.Texture2D; } } public static Texture2D Up { get { return Instance.up.Texture2D; } } + public static Texture2D BulletPoint { get { return Instance.bullet_point.Texture2D; } } public static Texture2D ChoiceNodeOff { get { return Instance.choice_node_off.Texture2D; } } public static Texture2D ChoiceNodeOn { get { return Instance.choice_node_on.Texture2D; } } public static Texture2D CommandBackground { get { return Instance.command_background.Texture2D; } } From abc4cb0a0732697d25608ba8399ac1ad00462b00 Mon Sep 17 00:00:00 2001 From: zvinless Date: Wed, 23 Nov 2016 22:30:39 -0800 Subject: [PATCH 20/22] Added newlines to switch for consistency --- Assets/Fungus/Scripts/Editor/FlowchartWindow.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index 5efdbdfa..11050ce3 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -371,17 +371,20 @@ namespace Fungus.EditorUtils centerBlock = true; useEvent = true; break; + case KeyCode.UpArrow: --blockPopupSelection; centerBlock = true; useEvent = true; break; + case KeyCode.Return: centerBlock = true; selectBlock = true; closePopup = true; useEvent = true; break; + case KeyCode.Escape: closePopup = true; useEvent = true; From 10f194a998d110da835192175a9461872d331f5b Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 28 Nov 2016 16:11:44 +0000 Subject: [PATCH 21/22] Added article by Marco Secchi --- Docs/fungus_docs/community_tutorials.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Docs/fungus_docs/community_tutorials.md b/Docs/fungus_docs/community_tutorials.md index 29ea5138..20289fec 100644 --- a/Docs/fungus_docs/community_tutorials.md +++ b/Docs/fungus_docs/community_tutorials.md @@ -3,6 +3,10 @@ If you've created an article or video about %Fungus let us know on the forum and we'll add it here. +# Marco Secchi # + +- [Interacting with a GameObject in Fungus](http://www.marcosecchi.it/2016/11/26/interacting-with-a-gameobject-in-fungus/?lang=en) + # Morning Fun Games # {#morning_fun} - [Custom Dialog Like A Comic](https://www.youtube.com/watch?v=RdCAjpQ3iGE) From 5a487df2084694bbd15b327a8b84b037768ce8dd Mon Sep 17 00:00:00 2001 From: Christopher Date: Wed, 30 Nov 2016 16:54:00 +0000 Subject: [PATCH 22/22] Fixed Sprite Object click skips writing Say Text #576 --- .../Scripts/EventHandlers/ObjectClicked.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs b/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs index d3c653ad..a103a1ef 100644 --- a/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs +++ b/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs @@ -2,6 +2,7 @@ // It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) using UnityEngine; +using System.Collections; namespace Fungus { @@ -17,6 +18,32 @@ namespace Fungus [Tooltip("Object that the user can click or tap on")] [SerializeField] protected Clickable2D clickableObject; + [Tooltip("Wait for a number of frames before executing the block.")] + [SerializeField] protected int waitFrames = 1; + + /// + /// Executing a block on the same frame that the object is clicked can cause + /// input problems (e.g. auto completing Say Dialog text). A single frame delay + /// fixes the problem. + /// + protected virtual IEnumerator DoExecuteBlock(int numFrames) + { + if (numFrames == 0) + { + ExecuteBlock(); + yield break; + } + + int count = Mathf.Max(waitFrames, 1); + while (count > 0) + { + count--; + yield return new WaitForEndOfFrame(); + } + + ExecuteBlock(); + } + #region Public members /// @@ -26,7 +53,7 @@ namespace Fungus { if (clickableObject == this.clickableObject) { - ExecuteBlock(); + StartCoroutine(DoExecuteBlock(waitFrames)); } }