@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 5ff164265158945c18b7d438b570ba22 |
||||
folderAsset: yes |
||||
timeCreated: 1478502248 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -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} |
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 4209d966cfca44792ad45389a996015e |
||||
timeCreated: 1434115586 |
||||
guid: 29cae11326cb84802b83fc3ff25a47e8 |
||||
timeCreated: 1478978272 |
||||
licenseType: Free |
||||
NativeFormatImporter: |
||||
userData: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 5e5a1319ef7f546a7affe3baabd5fba6 |
||||
folderAsset: yes |
||||
timeCreated: 1478502692 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
After Width: | Height: | Size: 865 B |
After Width: | Height: | Size: 865 B |
After Width: | Height: | Size: 1.1 KiB |
@ -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: |
After Width: | Height: | Size: 1.0 KiB |
@ -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: |
After Width: | Height: | Size: 1.1 KiB |
@ -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: |
After Width: | Height: | Size: 1.0 KiB |
@ -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: |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 982 B |
@ -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: |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@ -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} |
@ -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 |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ef64b0d30343049d4a634192975fab73 |
||||
timeCreated: 1434114816 |
||||
licenseType: Free |
||||
ShaderImporter: |
||||
defaultTextures: [] |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
@ -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 |
||||
{ |
||||
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 |
||||
// Handle reimporting all assets |
||||
internal class EditorResourcesPostProcessor : AssetPostprocessor |
||||
{ |
||||
private static void OnPostprocessAllAssets(string[] importedAssets, string[] _, string[] __, string[] ___) |
||||
{ |
||||
foreach (var path in importedAssets) |
||||
{ |
||||
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 |
||||
if (path.EndsWith("FungusEditorResources.asset")) |
||||
{ |
||||
var asset = AssetDatabase.LoadAssetAtPath(path, typeof(FungusEditorResources)) as FungusEditorResources; |
||||
if (asset != null) |
||||
{ |
||||
FungusEditorResources.UpdateTextureReferences(asset); |
||||
AssetDatabase.SaveAssets(); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
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" |
||||
}; |
||||
internal partial class FungusEditorResources : ScriptableObject |
||||
{ |
||||
[Serializable] |
||||
internal class EditorTexture |
||||
{ |
||||
[SerializeField] private Texture2D free; |
||||
[SerializeField] private Texture2D pro; |
||||
|
||||
public static Texture2D texCommandBackground |
||||
public Texture2D Texture2D |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.command_background]; } |
||||
get { return EditorGUIUtility.isProSkin && pro != null ? pro : free; } |
||||
} |
||||
|
||||
public static Texture2D texEventNodeOn |
||||
public EditorTexture(Texture2D free, Texture2D pro) |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.event_node_on]; } |
||||
this.free = free; |
||||
this.pro = pro; |
||||
} |
||||
} |
||||
|
||||
public static Texture2D texEventNodeOff |
||||
private static FungusEditorResources instance; |
||||
private static readonly string editorResourcesFolderName = "\"EditorResources\""; |
||||
[SerializeField] [HideInInspector] private bool updateOnReloadScripts = false; |
||||
|
||||
internal static FungusEditorResources Instance |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.event_node_off]; } |
||||
} |
||||
get |
||||
{ |
||||
if (instance == null) |
||||
{ |
||||
var guids = AssetDatabase.FindAssets("FungusEditorResources t:FungusEditorResources"); |
||||
|
||||
public static Texture2D texProcessNodeOn |
||||
if (guids.Length == 0) |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.process_node_on]; } |
||||
instance = ScriptableObject.CreateInstance(typeof(FungusEditorResources)) as FungusEditorResources; |
||||
AssetDatabase.CreateAsset(instance, GetRootFolder() + "/FungusEditorResources.asset"); |
||||
} |
||||
|
||||
public static Texture2D texProcessNodeOff |
||||
else |
||||
{ |
||||
if (guids.Length > 1) |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.process_node_off]; } |
||||
Debug.LogWarning("Multiple FungusEditorResources assets found!"); |
||||
} |
||||
|
||||
public static Texture2D texChoiceNodeOn |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.choice_node_on]; } |
||||
var path = AssetDatabase.GUIDToAssetPath(guids[0]); |
||||
instance = AssetDatabase.LoadAssetAtPath(path, typeof(FungusEditorResources)) as FungusEditorResources; |
||||
} |
||||
} |
||||
|
||||
public static Texture2D texChoiceNodeOff |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.choice_node_off]; } |
||||
return instance; |
||||
} |
||||
} |
||||
|
||||
public static Texture2D texPlayBig |
||||
private static string GetRootFolder() |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.play_big]; } |
||||
var rootGuid = AssetDatabase.FindAssets(editorResourcesFolderName)[0]; |
||||
return AssetDatabase.GUIDToAssetPath(rootGuid); |
||||
} |
||||
|
||||
public static Texture2D texPlaySmall |
||||
internal static void GenerateResourcesScript() |
||||
{ |
||||
get { return s_Cached[(int)ResourceName.play_small]; } |
||||
// Get all unique filenames |
||||
var textureNames = new HashSet<string>(); |
||||
var guids = AssetDatabase.FindAssets("t:Texture2D", new [] { GetRootFolder() }); |
||||
var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)); |
||||
|
||||
foreach (var path in paths) |
||||
{ |
||||
textureNames.Add(Path.GetFileNameWithoutExtension(path)); |
||||
} |
||||
|
||||
public static Texture2D texItemSplitter { get; private set; } |
||||
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); |
||||
|
||||
private static void GenerateSpecialTextures() |
||||
using (var writer = new StreamWriter(absolutePath)) |
||||
{ |
||||
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); |
||||
} |
||||
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(" {"); |
||||
|
||||
public static Texture2D CreatePixelTexture(string name, Color color) |
||||
foreach (var name in textureNames) |
||||
{ |
||||
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; |
||||
writer.WriteLine(" [SerializeField] private EditorTexture " + name + ";"); |
||||
} |
||||
|
||||
private static Texture2D[] s_Cached; |
||||
writer.WriteLine(""); |
||||
|
||||
public static void LoadResourceAssets() |
||||
foreach (var name in textureNames) |
||||
{ |
||||
var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin; |
||||
s_Cached = new Texture2D[skin.Length]; |
||||
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; } }"); |
||||
} |
||||
|
||||
for (int i = 0; i < s_Cached.Length; ++i) |
||||
{ |
||||
s_Cached[i] = Resources.Load("Textures/" + skin[i]) as Texture2D; |
||||
writer.WriteLine(" }"); |
||||
writer.WriteLine("}"); |
||||
} |
||||
|
||||
s_LightSkin = null; |
||||
s_DarkSkin = null; |
||||
Instance.updateOnReloadScripts = true; |
||||
AssetDatabase.ImportAsset(relativePath); |
||||
} |
||||
|
||||
private static void GetImageSize(byte[] imageData, out int width, out int height) |
||||
[DidReloadScripts] |
||||
private static void OnDidReloadScripts() |
||||
{ |
||||
if (Instance.updateOnReloadScripts) |
||||
{ |
||||
width = ReadInt(imageData, 3 + 15); |
||||
height = ReadInt(imageData, 3 + 15 + 2 + 2); |
||||
UpdateTextureReferences(Instance); |
||||
} |
||||
} |
||||
|
||||
internal static void UpdateTextureReferences(FungusEditorResources instance) |
||||
{ |
||||
// Iterate through all fields in instance and set texture references |
||||
var serializedObject = new SerializedObject(instance); |
||||
var prop = serializedObject.GetIterator(); |
||||
var rootFolder = new [] { GetRootFolder() }; |
||||
|
||||
private static int ReadInt(byte[] imageData, int offset) |
||||
prop.NextVisible(true); |
||||
while (prop.NextVisible(false)) |
||||
{ |
||||
return (imageData[offset] << 8) | imageData[offset + 1]; |
||||
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 |
||||
} |
||||
} |
||||
} |
@ -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; } } |
||||
} |
||||
} |
@ -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: |
@ -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 |
||||
{ |
||||
/// <summary> |
||||
/// 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" |
||||
/// </summary> |
||||
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; |
||||
} |
||||
} |
||||
} |