diff --git a/Assets/Fungus/EditorResources.meta b/Assets/Fungus/EditorResources.meta new file mode 100644 index 00000000..81e8ab72 --- /dev/null +++ b/Assets/Fungus/EditorResources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5ff164265158945c18b7d438b570ba22 +folderAsset: yes +timeCreated: 1478502248 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/EditorResources/FungusEditorResources.asset b/Assets/Fungus/EditorResources/FungusEditorResources.asset new file mode 100644 index 00000000..05ea3abc --- /dev/null +++ b/Assets/Fungus/EditorResources/FungusEditorResources.asset @@ -0,0 +1,65 @@ +%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} + 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} + 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} + 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} + 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/Resources/GLLineDraw.mat.meta b/Assets/Fungus/EditorResources/FungusEditorResources.asset.meta similarity index 65% rename from Assets/Fungus/Resources/GLLineDraw.mat.meta rename to Assets/Fungus/EditorResources/FungusEditorResources.asset.meta index 9d6a27d2..c92acc45 100644 --- a/Assets/Fungus/Resources/GLLineDraw.mat.meta +++ b/Assets/Fungus/EditorResources/FungusEditorResources.asset.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 4209d966cfca44792ad45389a996015e -timeCreated: 1434115586 +guid: 29cae11326cb84802b83fc3ff25a47e8 +timeCreated: 1478978272 licenseType: Free NativeFormatImporter: userData: diff --git a/Assets/Fungus/Resources/Icons.meta b/Assets/Fungus/EditorResources/Icons.meta similarity index 100% rename from Assets/Fungus/Resources/Icons.meta rename to Assets/Fungus/EditorResources/Icons.meta diff --git a/Assets/Fungus/EditorResources/Icons/Pro.meta b/Assets/Fungus/EditorResources/Icons/Pro.meta new file mode 100644 index 00000000..9dab8a98 --- /dev/null +++ b/Assets/Fungus/EditorResources/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/EditorResources/Icons/Pro/add.png b/Assets/Fungus/EditorResources/Icons/Pro/add.png new file mode 100644 index 00000000..23646d93 Binary files /dev/null and b/Assets/Fungus/EditorResources/Icons/Pro/add.png differ diff --git a/Assets/Fungus/Resources/Icons/left.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/add.png.meta similarity index 77% rename from Assets/Fungus/Resources/Icons/left.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/add.png.meta index 546dd74e..422af796 100644 --- a/Assets/Fungus/Resources/Icons/left.png.meta +++ b/Assets/Fungus/EditorResources/Icons/Pro/add.png.meta @@ -1,5 +1,7 @@ fileFormatVersion: 2 -guid: c0a7a4711d69249ab9dae1539a3247ee +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/EditorResources/Icons/Pro/add_small.png b/Assets/Fungus/EditorResources/Icons/Pro/add_small.png new file mode 100644 index 00000000..cf6b201e Binary files /dev/null and b/Assets/Fungus/EditorResources/Icons/Pro/add_small.png differ diff --git a/Assets/Fungus/Resources/Icons/right.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/add_small.png.meta similarity index 77% rename from Assets/Fungus/Resources/Icons/right.png.meta rename to Assets/Fungus/EditorResources/Icons/Pro/add_small.png.meta index 7c6971a5..4c2c0a2a 100644 --- a/Assets/Fungus/Resources/Icons/right.png.meta +++ b/Assets/Fungus/EditorResources/Icons/Pro/add_small.png.meta @@ -1,5 +1,7 @@ fileFormatVersion: 2 -guid: b3dd8b25a62664f379cb3714060d4e33 +guid: 64534dfaa17844231a9a9dd2df89d0db +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/EditorResources/Icons/Pro/delete.png b/Assets/Fungus/EditorResources/Icons/Pro/delete.png new file mode 100644 index 00000000..5cba698b Binary files /dev/null and b/Assets/Fungus/EditorResources/Icons/Pro/delete.png differ diff --git a/Assets/Fungus/EditorResources/Icons/Pro/delete.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/delete.png.meta new file mode 100644 index 00000000..da792108 --- /dev/null +++ b/Assets/Fungus/EditorResources/Icons/Pro/delete.png.meta @@ -0,0 +1,59 @@ +fileFormatVersion: 2 +guid: 29c4d29b1678042a5b3516c732ccc507 +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/EditorResources/Icons/Pro/down.png b/Assets/Fungus/EditorResources/Icons/Pro/down.png new file mode 100644 index 00000000..b84dbd53 Binary files /dev/null and b/Assets/Fungus/EditorResources/Icons/Pro/down.png differ diff --git a/Assets/Fungus/EditorResources/Icons/Pro/down.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/down.png.meta new file mode 100644 index 00000000..9dba1d7d --- /dev/null +++ b/Assets/Fungus/EditorResources/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/EditorResources/Icons/Pro/duplicate.png b/Assets/Fungus/EditorResources/Icons/Pro/duplicate.png new file mode 100644 index 00000000..7a36f572 Binary files /dev/null and b/Assets/Fungus/EditorResources/Icons/Pro/duplicate.png differ diff --git a/Assets/Fungus/EditorResources/Icons/Pro/duplicate.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/duplicate.png.meta new file mode 100644 index 00000000..bbf8b3b3 --- /dev/null +++ b/Assets/Fungus/EditorResources/Icons/Pro/duplicate.png.meta @@ -0,0 +1,59 @@ +fileFormatVersion: 2 +guid: 2f17490d993c84bd7872ef6588ffba47 +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/EditorResources/Icons/Pro/up.png b/Assets/Fungus/EditorResources/Icons/Pro/up.png new file mode 100644 index 00000000..e88161cc Binary files /dev/null and b/Assets/Fungus/EditorResources/Icons/Pro/up.png differ diff --git a/Assets/Fungus/EditorResources/Icons/Pro/up.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/up.png.meta new file mode 100644 index 00000000..2371a0d0 --- /dev/null +++ b/Assets/Fungus/EditorResources/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/EditorResources/Icons/add.png similarity index 100% rename from Assets/Fungus/Resources/Icons/add.png rename to Assets/Fungus/EditorResources/Icons/add.png diff --git a/Assets/Fungus/Resources/Icons/add.png.meta b/Assets/Fungus/EditorResources/Icons/add.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/add.png.meta rename to Assets/Fungus/EditorResources/Icons/add.png.meta diff --git a/Assets/Fungus/Resources/Icons/add_small.png b/Assets/Fungus/EditorResources/Icons/add_small.png similarity index 100% rename from Assets/Fungus/Resources/Icons/add_small.png rename to Assets/Fungus/EditorResources/Icons/add_small.png diff --git a/Assets/Fungus/Resources/Icons/add_small.png.meta b/Assets/Fungus/EditorResources/Icons/add_small.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/add_small.png.meta rename to Assets/Fungus/EditorResources/Icons/add_small.png.meta diff --git a/Assets/Fungus/Resources/Icons/delete.png b/Assets/Fungus/EditorResources/Icons/delete.png similarity index 100% rename from Assets/Fungus/Resources/Icons/delete.png rename to Assets/Fungus/EditorResources/Icons/delete.png diff --git a/Assets/Fungus/Resources/Icons/delete.png.meta b/Assets/Fungus/EditorResources/Icons/delete.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/delete.png.meta rename to Assets/Fungus/EditorResources/Icons/delete.png.meta diff --git a/Assets/Fungus/Resources/Icons/down.png b/Assets/Fungus/EditorResources/Icons/down.png similarity index 100% rename from Assets/Fungus/Resources/Icons/down.png rename to Assets/Fungus/EditorResources/Icons/down.png diff --git a/Assets/Fungus/Resources/Icons/down.png.meta b/Assets/Fungus/EditorResources/Icons/down.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/down.png.meta rename to Assets/Fungus/EditorResources/Icons/down.png.meta diff --git a/Assets/Fungus/Resources/Icons/duplicate.png b/Assets/Fungus/EditorResources/Icons/duplicate.png similarity index 100% rename from Assets/Fungus/Resources/Icons/duplicate.png rename to Assets/Fungus/EditorResources/Icons/duplicate.png diff --git a/Assets/Fungus/Resources/Icons/duplicate.png.meta b/Assets/Fungus/EditorResources/Icons/duplicate.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/duplicate.png.meta rename to Assets/Fungus/EditorResources/Icons/duplicate.png.meta diff --git a/Assets/Fungus/Resources/Icons/up.png b/Assets/Fungus/EditorResources/Icons/up.png similarity index 100% rename from Assets/Fungus/Resources/Icons/up.png rename to Assets/Fungus/EditorResources/Icons/up.png diff --git a/Assets/Fungus/Resources/Icons/up.png.meta b/Assets/Fungus/EditorResources/Icons/up.png.meta similarity index 100% rename from Assets/Fungus/Resources/Icons/up.png.meta rename to Assets/Fungus/EditorResources/Icons/up.png.meta diff --git a/Assets/Fungus/Resources/Textures.meta b/Assets/Fungus/EditorResources/Textures.meta similarity index 100% rename from Assets/Fungus/Resources/Textures.meta rename to Assets/Fungus/EditorResources/Textures.meta diff --git a/Assets/Fungus/EditorResources/Textures/bullet_point.png b/Assets/Fungus/EditorResources/Textures/bullet_point.png new file mode 100644 index 00000000..bcafc733 Binary files /dev/null and b/Assets/Fungus/EditorResources/Textures/bullet_point.png differ diff --git a/Assets/Fungus/Resources/Icons/ResizeHandle.png.meta b/Assets/Fungus/EditorResources/Textures/bullet_point.png.meta similarity index 87% rename from Assets/Fungus/Resources/Icons/ResizeHandle.png.meta rename to Assets/Fungus/EditorResources/Textures/bullet_point.png.meta index 3e1acd01..300a162f 100644 --- a/Assets/Fungus/Resources/Icons/ResizeHandle.png.meta +++ b/Assets/Fungus/EditorResources/Textures/bullet_point.png.meta @@ -1,5 +1,7 @@ fileFormatVersion: 2 -guid: c8b63a574d777374a918f2900930e540 +guid: 4ef739c68bb234717a60a2bb83ff8602 +timeCreated: 1479950896 +licenseType: Pro TextureImporter: fileIDToRecycleName: {} serializedVersion: 2 @@ -21,13 +23,13 @@ TextureImporter: grayScaleToAlpha: 0 generateCubemap: 0 cubemapConvolution: 0 - cubemapConvolutionSteps: 8 + cubemapConvolutionSteps: 7 cubemapConvolutionExponent: 1.5 seamlessCubemap: 0 textureFormat: -3 - maxTextureSize: 1024 + maxTextureSize: 2048 textureSettings: - filterMode: -1 + filterMode: 0 aniso: 1 mipBias: -1 wrapMode: 1 diff --git a/Assets/Fungus/Resources/Textures/choice_node_off.png b/Assets/Fungus/EditorResources/Textures/choice_node_off.png similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_off.png rename to Assets/Fungus/EditorResources/Textures/choice_node_off.png diff --git a/Assets/Fungus/Resources/Textures/choice_node_off.png.meta b/Assets/Fungus/EditorResources/Textures/choice_node_off.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_off.png.meta rename to Assets/Fungus/EditorResources/Textures/choice_node_off.png.meta diff --git a/Assets/Fungus/Resources/Textures/choice_node_on.png b/Assets/Fungus/EditorResources/Textures/choice_node_on.png similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_on.png rename to Assets/Fungus/EditorResources/Textures/choice_node_on.png diff --git a/Assets/Fungus/Resources/Textures/choice_node_on.png.meta b/Assets/Fungus/EditorResources/Textures/choice_node_on.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/choice_node_on.png.meta rename to Assets/Fungus/EditorResources/Textures/choice_node_on.png.meta diff --git a/Assets/Fungus/Resources/Textures/command_background.png b/Assets/Fungus/EditorResources/Textures/command_background.png similarity index 100% rename from Assets/Fungus/Resources/Textures/command_background.png rename to Assets/Fungus/EditorResources/Textures/command_background.png diff --git a/Assets/Fungus/Resources/Textures/command_background.png.meta b/Assets/Fungus/EditorResources/Textures/command_background.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/command_background.png.meta rename to Assets/Fungus/EditorResources/Textures/command_background.png.meta diff --git a/Assets/Fungus/EditorResources/Textures/connection_point.png b/Assets/Fungus/EditorResources/Textures/connection_point.png new file mode 100644 index 00000000..5a6719e7 Binary files /dev/null and b/Assets/Fungus/EditorResources/Textures/connection_point.png differ 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/Resources/Textures/event_node_off.png b/Assets/Fungus/EditorResources/Textures/event_node_off.png similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_off.png rename to Assets/Fungus/EditorResources/Textures/event_node_off.png diff --git a/Assets/Fungus/Resources/Textures/event_node_off.png.meta b/Assets/Fungus/EditorResources/Textures/event_node_off.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_off.png.meta rename to Assets/Fungus/EditorResources/Textures/event_node_off.png.meta diff --git a/Assets/Fungus/Resources/Textures/event_node_on.png b/Assets/Fungus/EditorResources/Textures/event_node_on.png similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_on.png rename to Assets/Fungus/EditorResources/Textures/event_node_on.png diff --git a/Assets/Fungus/Resources/Textures/event_node_on.png.meta b/Assets/Fungus/EditorResources/Textures/event_node_on.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/event_node_on.png.meta rename to Assets/Fungus/EditorResources/Textures/event_node_on.png.meta diff --git a/Assets/Fungus/Resources/Textures/play_big.png b/Assets/Fungus/EditorResources/Textures/play_big.png similarity index 100% rename from Assets/Fungus/Resources/Textures/play_big.png rename to Assets/Fungus/EditorResources/Textures/play_big.png diff --git a/Assets/Fungus/Resources/Textures/play_big.png.meta b/Assets/Fungus/EditorResources/Textures/play_big.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/play_big.png.meta rename to Assets/Fungus/EditorResources/Textures/play_big.png.meta diff --git a/Assets/Fungus/Resources/Textures/play_small.png b/Assets/Fungus/EditorResources/Textures/play_small.png similarity index 100% rename from Assets/Fungus/Resources/Textures/play_small.png rename to Assets/Fungus/EditorResources/Textures/play_small.png diff --git a/Assets/Fungus/Resources/Textures/play_small.png.meta b/Assets/Fungus/EditorResources/Textures/play_small.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/play_small.png.meta rename to Assets/Fungus/EditorResources/Textures/play_small.png.meta diff --git a/Assets/Fungus/Resources/Textures/process_node_off.png b/Assets/Fungus/EditorResources/Textures/process_node_off.png similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_off.png rename to Assets/Fungus/EditorResources/Textures/process_node_off.png diff --git a/Assets/Fungus/Resources/Textures/process_node_off.png.meta b/Assets/Fungus/EditorResources/Textures/process_node_off.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_off.png.meta rename to Assets/Fungus/EditorResources/Textures/process_node_off.png.meta diff --git a/Assets/Fungus/Resources/Textures/process_node_on.png b/Assets/Fungus/EditorResources/Textures/process_node_on.png similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_on.png rename to Assets/Fungus/EditorResources/Textures/process_node_on.png diff --git a/Assets/Fungus/Resources/Textures/process_node_on.png.meta b/Assets/Fungus/EditorResources/Textures/process_node_on.png.meta similarity index 100% rename from Assets/Fungus/Resources/Textures/process_node_on.png.meta rename to Assets/Fungus/EditorResources/Textures/process_node_on.png.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.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: diff --git a/Assets/Fungus/Resources/Icons/ResizeHandle.png b/Assets/Fungus/Resources/Icons/ResizeHandle.png deleted file mode 100644 index aedc1d2e..00000000 Binary files a/Assets/Fungus/Resources/Icons/ResizeHandle.png and /dev/null differ diff --git a/Assets/Fungus/Resources/Icons/left.png b/Assets/Fungus/Resources/Icons/left.png deleted file mode 100644 index 9891f504..00000000 Binary files a/Assets/Fungus/Resources/Icons/left.png and /dev/null differ diff --git a/Assets/Fungus/Resources/Icons/right.png b/Assets/Fungus/Resources/Icons/right.png deleted file mode 100644 index 416a491a..00000000 Binary files a/Assets/Fungus/Resources/Icons/right.png and /dev/null differ 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/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index 350e9268..db037c2c 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -41,11 +41,11 @@ namespace Fungus.EditorUtils protected virtual void OnEnable() { - upIcon = Resources.Load("Icons/up") as Texture2D; - downIcon = Resources.Load("Icons/down") as Texture2D; - addIcon = Resources.Load("Icons/add") as Texture2D; - duplicateIcon = Resources.Load("Icons/duplicate") as Texture2D; - deleteIcon = Resources.Load("Icons/delete") as Texture2D; + upIcon = FungusEditorResources.Up; + downIcon = FungusEditorResources.Down; + addIcon = FungusEditorResources.Add; + duplicateIcon = FungusEditorResources.Duplicate; + deleteIcon = FungusEditorResources.Delete; } public virtual void DrawBlockName(Flowchart flowchart) diff --git a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs index 1a141553..117a7f40 100644 --- a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs @@ -213,7 +213,7 @@ namespace Fungus.EditorUtils string commandName = commandInfoAttr.CommandName; GUIStyle commandLabelStyle = new GUIStyle(GUI.skin.box); - commandLabelStyle.normal.background = FungusEditorResources.texCommandBackground; + commandLabelStyle.normal.background = FungusEditorResources.CommandBackground; int borderSize = 5; commandLabelStyle.border.top = borderSize; commandLabelStyle.border.bottom = borderSize; @@ -420,7 +420,7 @@ namespace Fungus.EditorUtils alpha = Mathf.Clamp01(alpha); GUI.color = new Color(1f, 1f, 1f, alpha); - GUI.Label(iconRect, FungusEditorResources.texPlaySmall, new GUIStyle()); + GUI.Label(iconRect, FungusEditorResources.PlaySmall, new GUIStyle()); GUI.color = storeColor; } diff --git a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs index a02cd3f5..a05b6d2c 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs @@ -50,7 +50,7 @@ namespace Fungus.EditorUtils luaEnvironmentProp = serializedObject.FindProperty("luaEnvironment"); luaBindingNameProp = serializedObject.FindProperty("luaBindingName"); - addTexture = Resources.Load("Icons/add_small") as Texture2D; + addTexture = FungusEditorResources.AddSmall; } public override void OnInspectorGUI() diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index a0df30f9..11050ce3 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -3,16 +3,108 @@ using UnityEngine; using UnityEditor; -using UnityEditorInternal; 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); + newCommand.ItemId = flowchart.NextItemId(); + newBlock.CommandList.Add(newCommand); + } + + // Copy event handler + if (eventHandler != null) + { + var newEventHandler = Undo.AddComponent(flowchart.gameObject, eventHandler.type) as EventHandler; + CopyProperties(eventHandler.serializedObject, newEventHandler); + newEventHandler.ParentBlock = newBlock; + 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; + } + } + + protected struct BlockGraphics + { + internal Color tint; + internal Texture2D onTexture; + internal Texture2D offTexture; + } + + protected List copyList = new List(); public static List deleteList = new List(); protected List windowBlockMap = new List(); @@ -34,11 +126,29 @@ namespace Fungus.EditorUtils protected int forceRepaintCount; protected Texture2D addTexture; + protected Texture2D connectionPointTexture; protected Rect selectionBox; - protected Vector2 startSelectionBoxPosition = new Vector2(-1.0f, -1.0f); + 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; + protected const float rightClickTolerance = 5f; + + 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() { @@ -60,7 +170,13 @@ namespace Fungus.EditorUtils nodeStyle.alignment = TextAnchor.MiddleCenter; nodeStyle.wordWrap = true; - addTexture = Resources.Load("Icons/add_small") as Texture2D; + addTexture = FungusEditorResources.AddSmall; + connectionPointTexture = FungusEditorResources.ConnectionPoint; + gridLineColor.a = EditorGUIUtility.isProSkin ? 0.5f : 0.25f; + + copyList.Clear(); + + wantsMouseMove = true; // For hover selection in block search popup } protected virtual void OnInspectorUpdate() @@ -150,24 +266,51 @@ namespace Fungus.EditorUtils { Undo.DestroyObjectImmediate(command); } + + if (deleteBlock._EventHandler != null) + { + Undo.DestroyObjectImmediate(deleteBlock._EventHandler); + } Undo.DestroyObjectImmediate((Block)deleteBlock); flowchart.ClearSelectedCommands(); if (isSelected) { + // Deselect + flowchart.SelectedBlocks.Remove(deleteBlock); + // Revert to showing properties for the Flowchart Selection.activeGameObject = flowchart.gameObject; } } deleteList.Clear(); + // Clear search filter focus + if (Event.current.type == EventType.MouseDown && !searchRect.Contains(Event.current.mousePosition) && + !popupRect.Contains(Event.current.mousePosition)) + { + CloseBlockPopup(); + } + + if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) + { + if (GUI.GetNameOfFocusedControl() != searchFieldName && flowchart.SelectedBlocks.Count > 0) + { + DeselectAll(flowchart); + Event.current.Use(); + } + } + DrawFlowchartView(flowchart); DrawOverlay(flowchart); // 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 @@ -197,7 +340,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)) { @@ -206,6 +352,100 @@ 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); + 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"))) + { + CloseBlockPopup(); + } + GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); @@ -253,7 +493,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(); @@ -263,6 +505,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) @@ -285,18 +596,45 @@ 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); + // 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) + { + if (Vector2.Distance(rightClickDown, Event.current.mousePosition) > rightClickTolerance) + { + rightClickDown = -Vector2.one; + } + } + } + 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. - CalcFlowchartCenter(flowchart, blocks); + if (flowchart != null && blocks.Length > 0) + { + CalcFlowchartCenter(flowchart, blocks); + } // Draw connections foreach (var block in blocks) @@ -440,7 +778,7 @@ namespace Fungus.EditorUtils GUI.color = new Color(1f, 1f, 1f, alpha); } - if (GUI.Button(rect, FungusEditorResources.texPlayBig as Texture, new GUIStyle())) + if (GUI.Button(rect, FungusEditorResources.PlayBig, new GUIStyle())) { SelectBlock(flowchart, b); } @@ -452,18 +790,64 @@ namespace Fungus.EditorUtils PanAndZoom(flowchart); - 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 && + rightClickDown != -Vector2.one && !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, () => 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(); + 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 +858,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 +876,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 +946,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); @@ -609,7 +996,7 @@ namespace Fungus.EditorUtils bool zoom = false; // Scroll wheel - if (Event.current.type == EventType.ScrollWheel) + if (Event.current.type == EventType.ScrollWheel && !mouseOverPopup) { zoom = true; } @@ -648,26 +1035,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; } @@ -676,10 +1051,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) @@ -688,6 +1065,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) { @@ -701,18 +1086,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]; @@ -781,44 +1154,7 @@ namespace Fungus.EditorUtils } GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle); - Texture2D offTex; - Texture2D onTex; - Color defaultColor; - - if (block._EventHandler != null) - { - offTex = FungusEditorResources.texEventNodeOff; - onTex = FungusEditorResources.texEventNodeOn; - 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.texChoiceNodeOff; - onTex = FungusEditorResources.texChoiceNodeOn; - defaultColor = FungusConstants.DefaultChoiceBlockTint; - } - else - { - offTex = FungusEditorResources.texProcessNodeOff; - onTex = FungusEditorResources.texProcessNodeOn; - defaultColor = FungusConstants.DefaultProcessBlockTint; - } - } + var graphics = GetBlockGraphics(block); // Make sure node is wide enough to fit the node name text var n = block as Node; @@ -828,22 +1164,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; - nodeStyleCopy.normal.background = offTex; - GUI.backgroundColor = tintColor; + if (GUI.GetNameOfFocusedControl() == searchFieldName && !filteredBlocks.Contains(block)) + { + graphics.tint.a *= 0.2f; + } + + nodeStyleCopy.normal.background = graphics.offTexture; + GUI.backgroundColor = graphics.tint; GUI.Box(boxRect, block.BlockName, nodeStyleCopy); GUI.backgroundColor = Color.white; @@ -854,20 +1194,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) @@ -936,17 +1262,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; @@ -967,19 +1293,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) @@ -988,68 +1349,6 @@ namespace Fungus.EditorUtils blocks.ForEach(block => FlowchartWindow.deleteList.Add(block)); } - protected static void DuplicateBlocks(object obj) - { - var flowchart = GetFlowchart(); - - Undo.RecordObject(flowchart, "Select"); - flowchart.ClearSelectedBlocks(); - - var blocks = obj as List; - - foreach (var block in blocks) - { - Vector2 newPosition = new Vector2(block._NodeRect.position.x + - block._NodeRect.width + 20, - block._NodeRect.y); - - 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) @@ -1087,9 +1386,195 @@ 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(); + + 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 == "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" || c == "Find") + { + 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": + Duplicate(flowchart); + 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; + + 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/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs index 9c35cc05..411fab08 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs @@ -1,149 +1,222 @@ // 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 UnityEditor.Callbacks; 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 +namespace Fungus.EditorUtils { - internal static class FungusEditorResources + [CustomEditor(typeof(FungusEditorResources))] + internal class FungusEditorResourcesInspector : Editor { + public override void OnInspectorGUI() + { + if (serializedObject.FindProperty("updateOnReloadScripts").boolValue) + { + GUILayout.Label("Updating..."); + } + else + { + if (GUILayout.Button("Sync with EditorResources folder")) + { + FungusEditorResources.GenerateResourcesScript(); + } - static FungusEditorResources() { - GenerateSpecialTextures(); - LoadResourceAssets(); + DrawDefaultInspector(); + } } + } - 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" - }; - - 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" - }; - - public static Texture2D texCommandBackground + // Handle reimporting all assets + internal class EditorResourcesPostProcessor : AssetPostprocessor + { + private static void OnPostprocessAllAssets(string[] importedAssets, string[] _, string[] __, string[] ___) { - get { return s_Cached[(int)ResourceName.command_background]; } + 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; + } + } + } } + } - public static Texture2D texEventNodeOn - { - get { return s_Cached[(int)ResourceName.event_node_on]; } - } - - public static Texture2D texEventNodeOff + internal partial class FungusEditorResources : ScriptableObject + { + [Serializable] + internal class EditorTexture { - get { return s_Cached[(int)ResourceName.event_node_off]; } - } + [SerializeField] private Texture2D free; + [SerializeField] private Texture2D pro; - 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 Texture2D Texture2D + { + get { return EditorGUIUtility.isProSkin && pro != null ? pro : free; } + } - 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 EditorTexture(Texture2D free, Texture2D pro) + { + this.free = free; + this.pro = pro; + } } - public static Texture2D texPlayBig - { - get { return s_Cached[(int)ResourceName.play_big]; } - } + private static FungusEditorResources instance; + private static readonly string editorResourcesFolderName = "\"EditorResources\""; + [SerializeField] [HideInInspector] private bool updateOnReloadScripts = false; - public static Texture2D texPlaySmall + internal static FungusEditorResources Instance { - get { return s_Cached[(int)ResourceName.play_small]; } - } + get + { + if (instance == null) + { + var guids = AssetDatabase.FindAssets("FungusEditorResources t:FungusEditorResources"); - 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); + if (guids.Length == 0) + { + instance = ScriptableObject.CreateInstance(typeof(FungusEditorResources)) as FungusEditorResources; + AssetDatabase.CreateAsset(instance, GetRootFolder() + "/FungusEditorResources.asset"); + } + 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; + } + } + + return instance; + } } - - public static Texture2D CreatePixelTexture(string name, Color color) + + private static string GetRootFolder() { - 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; + var rootGuid = AssetDatabase.FindAssets(editorResourcesFolderName)[0]; + return AssetDatabase.GUIDToAssetPath(rootGuid); } - private static Texture2D[] s_Cached; - - public static void LoadResourceAssets() + internal static void GenerateResourcesScript() { - var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin; - s_Cached = new Texture2D[skin.Length]; + // Get all unique filenames + var textureNames = new HashSet(); + var guids = AssetDatabase.FindAssets("t:Texture2D", new [] { GetRootFolder() }); + var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)); - for (int i = 0; i < s_Cached.Length; ++i) + foreach (var path in paths) { - s_Cached[i] = Resources.Load("Textures/" + skin[i]) as Texture2D; + 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); - s_LightSkin = null; - s_DarkSkin = null; + 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 partial class FungusEditorResources : ScriptableObject"); + writer.WriteLine(" {"); + + foreach (var name in textureNames) + { + writer.WriteLine(" [SerializeField] private EditorTexture " + name + ";"); + } + + writer.WriteLine(""); + + foreach (var name in textureNames) + { + 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 Instance." + name + ".Texture2D; } }"); + } + + writer.WriteLine(" }"); + writer.WriteLine("}"); + } + + Instance.updateOnReloadScripts = true; + AssetDatabase.ImportAsset(relativePath); } - - private static void GetImageSize(byte[] imageData, out int width, out int height) + + [DidReloadScripts] + private static void OnDidReloadScripts() { - width = ReadInt(imageData, 3 + 15); - height = ReadInt(imageData, 3 + 15 + 2 + 2); + if (Instance.updateOnReloadScripts) + { + UpdateTextureReferences(Instance); + } } - - private static int ReadInt(byte[] imageData, int offset) + + internal static void UpdateTextureReferences(FungusEditorResources instance) { - return (imageData[offset] << 8) | imageData[offset + 1]; + // Iterate through all fields in instance and set texture references + var serializedObject = new SerializedObject(instance); + var prop = serializedObject.GetIterator(); + var rootFolder = new [] { GetRootFolder() }; + + prop.NextVisible(true); + while (prop.NextVisible(false)) + { + 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; + } + } + } + } + + serializedObject.FindProperty("updateOnReloadScripts").boolValue = 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 } } -} \ No newline at end of file +} diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs new file mode 100644 index 00000000..f7a0641b --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs @@ -0,0 +1,46 @@ +// 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 partial class FungusEditorResources : ScriptableObject + { + [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 bullet_point; + [SerializeField] private EditorTexture choice_node_off; + [SerializeField] private EditorTexture choice_node_on; + [SerializeField] private EditorTexture command_background; + [SerializeField] private EditorTexture connection_point; + [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 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 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; } } + public static Texture2D ConnectionPoint { get { return Instance.connection_point.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; } } + } +} diff --git a/Assets/Fungus/Scripts/Editor/GLDraw.cs.meta b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs.meta similarity index 52% rename from Assets/Fungus/Scripts/Editor/GLDraw.cs.meta rename to Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs.meta index 6f3fb05c..6d6fd014 100644 --- a/Assets/Fungus/Scripts/Editor/GLDraw.cs.meta +++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs.meta @@ -1,8 +1,12 @@ fileFormatVersion: 2 -guid: 5184535fd41514a0ebd42c1d70a53545 +guid: f5119f9bdde234916bed657bdc751f76 +timeCreated: 1478502142 +licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: + assetBundleName: + assetBundleVariant: 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/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)); } } 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} 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)