diff --git a/Documentation/instructions.md b/Documentation/instructions.md deleted file mode 100644 index 733fbed..0000000 --- a/Documentation/instructions.md +++ /dev/null @@ -1,192 +0,0 @@ - -# ElementAnimationToolkit - -[Documentation]("https://docs.instance.id/elementanimationtoolkit/") - -### A collection of Unity UIElements animation extension methods, new animated elements, and examples. -![](media/intro_animation.gif) - -### Note: UIElements Animations are listed as Experimental by Unity - API subject to change. Also, since Element Animation Toolkit is currently underactive development, it is possible for API changes in this library as well - -#### The intent of this package is to help asset developers more easily create their own animation sequences via code. -Though, I have been adding some new "ready to go" UIElement types, such as the "AnimatedFoldout", which you just use as you would a a typical foldout comes animated with no additional coding, minus some exposed properties to adjust the animation to your liking. I do intend to add more of these as I go along. - -This package began simply as a small collection of helpers methods I created across my last few projects to make animating editor elements much easier and finally put into a single place. I continue to add to it as I go along but decided to put together several examples and wanted to share them. - -### Install via OpenUPM -openupm add id.instance.elementanimationtoolkit - -### Unity Package Manager -https://github.com/instance-id/elementanimationtoolkit.git#upm - -### Usage: - -Examples: Tools > instance.id > Element Animation Toolkit - -Note: The code is pretty ~~heavily~~ excessively documented and currently most method summaries for extension methods have examples in them. Be sure to check the comments for additional details! - -![](https://i.imgur.com/hY3DGDA.png) - - -
-Example: Method IDE summary for 'HoverColor()' - -```cs -/// -/// Adds forecolor hover capability that will not be lost like CSS:hover when programatically setting background color -/// -/// -/// -/// var originalColor = GetColor.FromHex("#BABABA"); -/// var hoverColor = GetColor.FromHex("#2F569C"); -/// -/// label.HoverColor(originalColor, hoverColor); -/// -/// -``` -
- -There are several fairly basic base animation helper methods which can easily be used on their own, but are also the basis of the more complex animation sequences: - -### Background Color Fade-In -![](media/background_fade_example.gif) -(The initial fade from gray to blue) - -
-Example animation base helper: AnimateBackgroundColor() -Usage: - -```c# - -Color originalColor = GetColor.FromHex("#BABABA"); -Color fadeColor = GetColor.FromHex("#2F569C"); -var durationOfFade = 250; // In milliseconds - -VisualElement visualElement = new VisualElement(); -visualElement.AnimateBackgroundColor(originalColor, fadeColor, durationOfFade); - -``` - -
- ---- - -### Hover Border Pulse -![](media/hoverborderpulse_example.gif) -
-Example hover animation: HoverBorderPulse() - -Usage: - -```c# -VisualElement visualElement = new VisualElement(); -visualElement.HoverBorderPulse(pulseStartColor: GetColor.FromHex("#7F3B3A"), pulseEndColor: GetColor.FromHex("#2F569C"), colorDuration: 500); -``` - -
- ---- - -### Fade-in sequence -![](media/fade_example.gif) - -
-Example complex animation sequence: AnimFadeInSequence() - -Usage: - -```c# -Label label = new Label {text = "Click button to make me fade!"}; - -const int fadeInTime = 500; -const float displayTime = 2000f; -const int fadeOutTime = 500; -string newText = "then back to the original!"; -var originalTextColor = GetColor.FromHex("#BABABA"); -var animatedTextColor = GetColor.FromHex("#607FAE"); - -label.AnimFadeInSequence(newText, animatedTextColor, originalTextColor, fadeInTime, displayTime, fadeOutTime); -``` - -
- -Then, of course, there is everything in between. - -Additionally there are many helper methods relating to many different Types from Color to opening weblinks in the browser. - -
-Example color helper method: GetColor.FromHex() - -Usage: -```cs -Color color = GetColor.FromHex("#CCCCCC"); -``` - -Implementation: - -```cs -public static Color FromHex(this string color) -{ - if (!color.StartsWith("#")) Debug.LogWarning("The FromHex() function must be used on a hexadecimal string beginning with #"); - ColorUtility.TryParseHtmlString(color, out var outColor); - return outColor; -} -``` - -
- -
-Example creating an external url link : OpenURL() - -Usage: -```cs -VisualElement visualElement = new VisualElement(); -visualElement.OpenURL("https://github.com/instance-id/ElementAnimationToolkit"); -``` - -Implementation: - -```cs -public static T OpenURL(this T element, string url) where T : VisualElement -{ - element.RegisterCallback(evt => - { - if (evt.button == 0) - { - Application.OpenURL(url); - evt.StopPropagation(); - } - }); - - return element; -} -``` - -
- -Important files: - - Assets/instance.id/ElementAnimationToolkit/Editor/EATKEditor.cs -This file is the primary example and demonstrative reference for most major features and is the main editor window of the package -where you can view examples of several different types of animations and their usage. - -You can access the main editor window via Tools > instance.id > Element Animation Toolkit - -There are three buttons per row, Editor, Anim, and USS. - -![](media/rowbuttons.png) - -The editor button will take you directly to the editor code specific to that element where you will see the C# implementation of UIElements as well as most callback registrations. - -The Anim button takes you to another section of the file in which you can see the declaration, setup, and execution of any animation specific functions, - -Lastly is the USS button, which takes you to the USS stylesheet and the location of the particular animation if you need. - -The animations without a row of buttons have a right-click context menu implemented which has similar options to jump directly into -the code at the proper location for the animation. (The methods I have created for jumping straight to the proper lines of code -are of course included and you are welcome to take advantage of them for your own needs.) -![](media/jumptomenu.png) - - ---- -![alt text](https://i.imgur.com/cg5ow2M.png "instance.id") diff --git a/Documentation/instructions.md.meta b/Documentation/instructions.md.meta deleted file mode 100644 index eb5466d..0000000 --- a/Documentation/instructions.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 05b8c26a512a8e14ca8dd4714f568c22 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media.meta b/Documentation/media.meta deleted file mode 100644 index 4274c86..0000000 --- a/Documentation/media.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 432309b9fb72ac143a035300acd2a18c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media/background_fade_example.gif b/Documentation/media/background_fade_example.gif deleted file mode 100644 index 8b92063..0000000 Binary files a/Documentation/media/background_fade_example.gif and /dev/null differ diff --git a/Documentation/media/background_fade_example.gif.meta b/Documentation/media/background_fade_example.gif.meta deleted file mode 100644 index 041d1a1..0000000 --- a/Documentation/media/background_fade_example.gif.meta +++ /dev/null @@ -1,92 +0,0 @@ -fileFormatVersion: 2 -guid: 320acd0554bfabd4eb73008d91661a43 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media/fade_example.gif b/Documentation/media/fade_example.gif deleted file mode 100644 index 7def5f6..0000000 Binary files a/Documentation/media/fade_example.gif and /dev/null differ diff --git a/Documentation/media/fade_example.gif.meta b/Documentation/media/fade_example.gif.meta deleted file mode 100644 index 9f5f18e..0000000 --- a/Documentation/media/fade_example.gif.meta +++ /dev/null @@ -1,92 +0,0 @@ -fileFormatVersion: 2 -guid: 19cfe5e0b2e8a774192d576bb778a673 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media/hoverborderpulse_example.gif b/Documentation/media/hoverborderpulse_example.gif deleted file mode 100644 index b7dc2f8..0000000 Binary files a/Documentation/media/hoverborderpulse_example.gif and /dev/null differ diff --git a/Documentation/media/hoverborderpulse_example.gif.meta b/Documentation/media/hoverborderpulse_example.gif.meta deleted file mode 100644 index 657ba9e..0000000 --- a/Documentation/media/hoverborderpulse_example.gif.meta +++ /dev/null @@ -1,92 +0,0 @@ -fileFormatVersion: 2 -guid: 91bdfb4b421214a4ea4e60354669e15f -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media/intro_animation.gif b/Documentation/media/intro_animation.gif deleted file mode 100644 index 304dfb8..0000000 Binary files a/Documentation/media/intro_animation.gif and /dev/null differ diff --git a/Documentation/media/intro_animation.gif.meta b/Documentation/media/intro_animation.gif.meta deleted file mode 100644 index 4040e93..0000000 --- a/Documentation/media/intro_animation.gif.meta +++ /dev/null @@ -1,92 +0,0 @@ -fileFormatVersion: 2 -guid: 01f20adc67e2dad49a3425cc19b90692 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media/intro_animation.mp4 b/Documentation/media/intro_animation.mp4 deleted file mode 100644 index f99920c..0000000 Binary files a/Documentation/media/intro_animation.mp4 and /dev/null differ diff --git a/Documentation/media/intro_animation.mp4.meta b/Documentation/media/intro_animation.mp4.meta deleted file mode 100644 index 3fecece..0000000 --- a/Documentation/media/intro_animation.mp4.meta +++ /dev/null @@ -1,18 +0,0 @@ -fileFormatVersion: 2 -guid: 7cb5e5d9ec71c074b899d8b6a6d2be37 -VideoClipImporter: - externalObjects: {} - serializedVersion: 2 - frameRange: 0 - startFrame: -1 - endFrame: -1 - colorSpace: 0 - deinterlace: 0 - encodeAlpha: 0 - flipVertical: 0 - flipHorizontal: 0 - importAudio: 1 - targetSettings: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media/jumptomenu.png b/Documentation/media/jumptomenu.png deleted file mode 100644 index 7c40f3e..0000000 Binary files a/Documentation/media/jumptomenu.png and /dev/null differ diff --git a/Documentation/media/jumptomenu.png.meta b/Documentation/media/jumptomenu.png.meta deleted file mode 100644 index 37ac799..0000000 --- a/Documentation/media/jumptomenu.png.meta +++ /dev/null @@ -1,92 +0,0 @@ -fileFormatVersion: 2 -guid: 6c303c8a4caad8647826c03af9862b69 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Documentation/media/rowbuttons.png b/Documentation/media/rowbuttons.png deleted file mode 100644 index 0db4c8a..0000000 Binary files a/Documentation/media/rowbuttons.png and /dev/null differ diff --git a/Documentation/media/rowbuttons.png.meta b/Documentation/media/rowbuttons.png.meta deleted file mode 100644 index 275ff8f..0000000 --- a/Documentation/media/rowbuttons.png.meta +++ /dev/null @@ -1,92 +0,0 @@ -fileFormatVersion: 2 -guid: e1937972993ea194a981f55be5b33b3b -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 0 - spriteTessellationDetail: -1 - textureType: 0 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - applyGammaDecoding: 0 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor.meta b/Editor.meta deleted file mode 100644 index d0fa69b..0000000 --- a/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ec419ac487719f048a44bdd468cb1fac -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/id.instance.elementanimationtoolkit.Editor.asmdef b/Editor/id.instance.elementanimationtoolkit.Editor.asmdef deleted file mode 100644 index 5a2b508..0000000 --- a/Editor/id.instance.elementanimationtoolkit.Editor.asmdef +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "id.instance.elementanimationtoolkit.Editor", - "rootNamespace": "", - "references": [ - "id.instance.elementanimationtoolkit" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Editor/id.instance.elementanimationtoolkit.Editor.asmdef.meta b/Editor/id.instance.elementanimationtoolkit.Editor.asmdef.meta deleted file mode 100644 index 7b7dae1..0000000 --- a/Editor/id.instance.elementanimationtoolkit.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 38eb7655600ecc84794336a6c44b46e8 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Animations/AnimationExtensions.cs b/Runtime/Animations/AnimationExtensions.cs index 6de6cd7..1694847 100644 --- a/Runtime/Animations/AnimationExtensions.cs +++ b/Runtime/Animations/AnimationExtensions.cs @@ -19,7 +19,7 @@ public static class AnimationExtensions /// The amount of time in milliseconds that should be waited until the action begins public static void ExecuteIn(this VisualElement element, Action action, long delayMs = 0) { - element.schedule.Execute(action).StartingIn(delayMs); + element.parent.schedule.Execute(action).StartingIn(delayMs); } /// @@ -30,43 +30,7 @@ public static void ExecuteIn(this VisualElement element, Action action, long del /// The amount of time in milliseconds that should be waited until the action begins public static void ExecuteIn(this Action action, VisualElement element, long delayMs = 0) { - element.schedule.Execute(action).StartingIn(delayMs); - } - - // -- Register Callback with element return ------------ - /// - /// RegisterCallback on element, as well as children, and return the element - /// - /// The target element in which to register the callback - /// The callback in which to register - /// Register child elements in addition to the target element - /// The event callback type in which to register - /// The target element - public static VisualElement RegisterCallback(this VisualElement element, EventCallback callback, bool includeChildren, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) - where TEventType : EventBase, new() - { - element.RegisterCallback(callback); - if (!includeChildren) return element; - var children = element.Query().Descendents().ToList(); - children.ForEach(x => x.RegisterCallback(callback)); - return element; - } - - /// - /// RegisterCallback on element, as well as children, and return the element - /// - /// The target element in which to register the callback - /// The callback in which to register - /// Register child elements in addition to the target element - /// The event callback type in which to register - /// The target element - public static void UnregisterCallback(this VisualElement element, EventCallback callback, bool includeChildren, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) - where TEventType : EventBase, new() - { - element.UnregisterCallback(callback); - if (!includeChildren) return; - var children = element.Query().Descendents().ToList(); - children.ForEach(x => x.UnregisterCallback(callback)); + element.parent.schedule.Execute(action).StartingIn(delayMs); } } } diff --git a/Runtime/Animations/AnimationSequences.cs b/Runtime/Animations/AnimationSequences.cs index 3d031f2..506bcf5 100644 --- a/Runtime/Animations/AnimationSequences.cs +++ b/Runtime/Animations/AnimationSequences.cs @@ -10,8 +10,8 @@ using UnityEngine; using UnityEngine.UIElements; using System.Collections.Generic; -using instance.id.EATK.Extensions; using UnityEngine.UIElements.Experimental; +using instance.id.EATK.Extensions; namespace instance.id.EATK { diff --git a/Runtime/Animations/ContinuousAnimations.cs b/Runtime/Animations/ContinuousAnimations.cs index 2817bb6..1b21764 100644 --- a/Runtime/Animations/ContinuousAnimations.cs +++ b/Runtime/Animations/ContinuousAnimations.cs @@ -5,10 +5,10 @@ #if UNITY_EDITOR using System; -using instance.id.EATK.Extensions; using UnityEngine; using UnityEngine.UIElements; using UnityEngine.UIElements.Experimental; +using instance.id.EATK.Extensions; namespace instance.id.EATK { diff --git a/Runtime/Elements/AnimatedLabel/AnimatedLabel.cs b/Runtime/Elements/AnimatedLabel/AnimatedLabel.cs index effad7c..f7c07bb 100644 --- a/Runtime/Elements/AnimatedLabel/AnimatedLabel.cs +++ b/Runtime/Elements/AnimatedLabel/AnimatedLabel.cs @@ -4,12 +4,11 @@ // ---------------------------------------------------------------------------- #if UNITY_EDITOR - - using System; -using instance.id.EATK.Extensions; using UnityEngine; using UnityEngine.UIElements; +using instance.id.EATK.Extensions; + // ReSharper disable UnusedMember.Global #pragma warning disable 108,114 @@ -56,7 +55,7 @@ public AnimatedLabel() { editorType = GetType(); styleSheets.Add(StylesheetSetup()); - new Label {text = ""}.Create(out animatedLabel).ToUSS(nameof(animatedLabel)); + new Label { text = "" }.Create(out animatedLabel).ToUSS(nameof(animatedLabel)); animatedLabel.AddToClassList(ussClassNameExtended); Add(animatedLabel); @@ -76,9 +75,7 @@ internal Label GetLabel() // // } - public void Play() - { - } + public void Play() { } private StyleSheet StylesheetSetup() { @@ -139,33 +136,33 @@ public bool ClassListContains(string cls) } public void RegisterCallback( - EventCallback callback, - TUserArgsType userArgs, - TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) + EventCallback callback, + TUserArgsType userArgs, + TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEventType : EventBase, new() { animatedLabel.RegisterCallback(callback, userArgs, useTrickleDown); } public void UnregisterCallback( - EventCallback callback, - TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) + EventCallback callback, + TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEventType : EventBase, new() { animatedLabel.UnregisterCallback(callback, useTrickleDown); } public void UnregisterCallback( - EventCallback callback, - TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) + EventCallback callback, + TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEventType : EventBase, new() { animatedLabel.UnregisterCallback(callback, useTrickleDown); } public static bool RegisterValueChangedCallback( - INotifyValueChanged control, - EventCallback> callback) + INotifyValueChanged control, + EventCallback> callback) { if (!(control is CallbackEventHandler callbackEventHandler)) return false; @@ -174,8 +171,8 @@ public static bool RegisterValueChangedCallback( } public static bool UnregisterValueChangedCallback( - INotifyValueChanged control, - EventCallback> callback) + INotifyValueChanged control, + EventCallback> callback) { if (!(control is CallbackEventHandler callbackEventHandler)) return false; @@ -188,16 +185,12 @@ public static bool UnregisterValueChangedCallback( /// /// Instantiates a using the data read from a UXML file. /// - public new class UxmlFactory : UxmlFactory - { - } + public new class UxmlFactory : UxmlFactory { } /// /// Defines for the . /// - public new class UxmlTraits : TextElement.UxmlTraits - { - } + public new class UxmlTraits : TextElement.UxmlTraits { } } } #endif diff --git a/Runtime/Elements/BetterTextField/MaskedInputField.cs b/Runtime/Elements/BetterTextField/MaskedInputField.cs index dc38e8e..043da19 100644 --- a/Runtime/Elements/BetterTextField/MaskedInputField.cs +++ b/Runtime/Elements/BetterTextField/MaskedInputField.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using instance.id.EATK.Extensions; using JetBrains.Annotations; using UnityEngine; using UnityEngine.UIElements; - #if UNITY_EDITOR +using instance.id.EATK.Extensions; + +#if UNITY_EDITOR namespace instance.id.EATK { // Hopefully these features will eventually be in the default TextField. @@ -57,7 +58,7 @@ public MaskedInputField() maskedText = new TextField { - style = {display = DisplayStyle.Flex, position = Position.Absolute, unityFont = monoFont}, + style = { display = DisplayStyle.Flex, position = Position.Absolute, unityFont = monoFont }, value = "", pickingMode = PickingMode.Ignore, }; @@ -77,7 +78,7 @@ public MaskedInputField() }); // Add and configure placeholder - m_PlaceholderLabel = new Label {pickingMode = PickingMode.Ignore}; + m_PlaceholderLabel = new Label { pickingMode = PickingMode.Ignore }; m_PlaceholderLabel.AddToClassList(PlaceholderUssClassName); maskedText.Add(m_PlaceholderLabel); @@ -189,18 +190,16 @@ public override void SetValueWithoutNotify(string newValue) } [UsedImplicitly] - public new class UxmlFactory : UxmlFactory - { - } + public new class UxmlFactory : UxmlFactory { } public new class UxmlTraits : TextField.UxmlTraits { - readonly UxmlStringAttributeDescription m_Hint = new UxmlStringAttributeDescription {name = "placeholder"}; + readonly UxmlStringAttributeDescription m_Hint = new UxmlStringAttributeDescription { name = "placeholder" }; public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc) { base.Init(ve, bag, cc); - var field = (MaskedInputField) ve; + var field = (MaskedInputField)ve; field.Placeholder = m_Hint.GetValueFromBag(bag, cc); } } diff --git a/Runtime/Scripts/Extensions/CollectionExtensions.cs b/Runtime/Scripts/Extensions/CollectionExtensions.cs index 8c88060..e47b179 100644 --- a/Runtime/Scripts/Extensions/CollectionExtensions.cs +++ b/Runtime/Scripts/Extensions/CollectionExtensions.cs @@ -3,16 +3,16 @@ using System.Linq; using Object = UnityEngine.Object; -namespace instance.id.EATK.Extensions +namespace instance.id.EATK { - public static class CollectionExtensions + public static class CollectionExtension { // ------------------------------------------------------------------- Dictionary Functions // -- Dictionary Functions ---------------------------------------------------------------- #region Dictionary - public static Tvalue TryGet(this Dictionary dict, Tkey key) + public static Tvalue TryGetVal(this Dictionary dict, Tkey key) { dict.TryGetValue(key, out var value); return value; @@ -29,7 +29,7 @@ public static T GetOrAdd(this Dictionary dictionary, TKey key, dictionary.Add(key, result); return result; } - + public static bool TryAddValue(this IDictionary dictionary, TKey key, TValue value) { if (!dictionary.ContainsKey(key)) @@ -143,7 +143,7 @@ public static int GetKeyWidth(this Dictionary dictio // ------------------------------------------------------------------------- List Functions // -- List Functions ---------------------------------------------------------------------- - + #region List public static bool TryAddValue(this List list, TValue value) @@ -197,7 +197,7 @@ public static IEnumerable ForEachR(this List source, Action action, return forEach; } - + public static void ForEach(this IEnumerable ie, Action action) { foreach (var i in ie) @@ -217,7 +217,5 @@ public static void ForEach(this IEnumerable ie, Action action) } #endregion - - } } diff --git a/Runtime/Scripts/Extensions/ParseElements.cs b/Runtime/Scripts/Extensions/ParseElements.cs index e347e64..be58add 100644 --- a/Runtime/Scripts/Extensions/ParseElements.cs +++ b/Runtime/Scripts/Extensions/ParseElements.cs @@ -9,9 +9,8 @@ using UnityEngine; using UnityEngine.UIElements; using VisualElement = UnityEngine.UIElements.VisualElement; - #if UNITY_EDITOR - + namespace instance.id.EATK.Extensions { // ReSharper disable once InconsistentNaming diff --git a/Runtime/Scripts/Extensions/VisualElementExtension.cs b/Runtime/Scripts/Extensions/VisualElementExtension.cs index efafa51..3bb5577 100644 --- a/Runtime/Scripts/Extensions/VisualElementExtension.cs +++ b/Runtime/Scripts/Extensions/VisualElementExtension.cs @@ -8,12 +8,9 @@ using System.Linq; using UnityEngine; using UnityEngine.UIElements; - - using UnityEditor; using UnityEditor.UIElements; - namespace instance.id.EATK.Extensions { public static class VisualElementExtension @@ -115,7 +112,25 @@ public static T Create(this T element, string name = null) where T : VisualEl /// If a name is specifically passed as a parameter, it will be used, otherwise the target variable name is used /// Whether this element should be a row or column /// VisualElement - public static VisualElement CreateWithLabel(this T element, out VisualElement variable, string name = null, ContainerType containerType = ContainerType.Row, string labelText = default) where T : VisualElement + public static VisualElement CreateWithLabel(this T element, out VisualElement variable, string name = null, ContainerType containerType = ContainerType.Row, string labelText = default, float labelMinWidth = default) where T : VisualElement + { + StyleEnum direction = containerType == ContainerType.Row + ? new StyleEnum(FlexDirection.Row) + : new StyleEnum(FlexDirection.Column); + + if (name != null) element.name = name; + + new VisualElement { style = { flexDirection = direction } }.Create(out var elementContainer).ToUSS($"{element.name}Container", (containerType == ContainerType.Row ? "containerRow" : "containerColumn"), labelText); + if (labelMinWidth != default) new Label { text = labelText, style = { minWidth = labelMinWidth } }.Create().ToUSS($"{element.name}Label").SetParent(elementContainer); + else new Label { text = labelText }.Create().ToUSS($"{element.name}Label").SetParent(elementContainer); + + element.SetParent(elementContainer); + return variable = elementContainer; + } + + public static VisualElement CreateWithLabel(this T element, out VisualElement variable, string name = null, ContainerType containerType = ContainerType.Row, string labelText = default, float labelMinWidth = default, EventCallback> onValueChanged = null) + where T : VisualElement + where TE : struct { StyleEnum direction = containerType == ContainerType.Row ? new StyleEnum(FlexDirection.Row) @@ -124,7 +139,11 @@ public static VisualElement CreateWithLabel(this T element, out VisualElement if (name != null) element.name = name; new VisualElement { style = { flexDirection = direction } }.Create(out var elementContainer).ToUSS($"{element.name}Container", (containerType == ContainerType.Row ? "containerRow" : "containerColumn"), labelText); - new Label { text = labelText }.Create().ToUSS($"{element.name}Label").SetParent(elementContainer); + if (labelMinWidth != default) new Label { text = labelText, style = { minWidth = labelMinWidth } }.Create().ToUSS($"{element.name}Label").SetParent(elementContainer); + else new Label { text = labelText }.Create().ToUSS($"{element.name}Label").SetParent(elementContainer); + + if (onValueChanged != null) + element.RegisterCallback(onValueChanged); element.SetParent(elementContainer); return variable = elementContainer; @@ -526,7 +545,7 @@ public static float Zero(this float num) // ------------------------------------------------ Set Values /// - /// Set primary the color of the element + /// Set the primary color of the element /// /// The target element to apply color /// The color to apply to the primary element @@ -538,7 +557,7 @@ public static bool SetColor(this T element, Color color = default) where T : } /// - /// Set background the color of the element + /// Set the background color of the element /// /// The target element to apply background color /// The color to apply to the border @@ -548,7 +567,19 @@ public static bool SetBackgroundColor(this T element, Color color = default) if (element.style.backgroundColor != color) element.style.backgroundColor = color; return true; } - + + /// + /// Set the image tint color of the element + /// + /// The target element to apply background color + /// The color to apply to the border + /// VisualElement + public static bool SetBackgroundImageColor(this T element, Color color = default) where T : VisualElement + { + if (element.style.unityBackgroundImageTintColor != color) element.style.unityBackgroundImageTintColor = color; + return true; + } + /// /// Adds a border to all sides of the VisualElement /// @@ -640,6 +671,32 @@ public static T SetDisplay(this T element, bool value) where T : VisualElemen return element; } + /// + /// Set elements item alignment + /// + /// The Element in which to set alignment + /// The value in which to set + /// + /// Returns the original element to allow method chaining + public static T SetAlignItems(this T element, Align alignment) where T : VisualElement + { + element.style.alignItems = alignment; + return element; + } + + /// + /// Set elements content justification + /// + /// The Element in which to set alignment + /// The value in which to set + /// + /// Returns the original element to allow method chaining + public static T SetJustify(this T element, Justify justify) where T : VisualElement + { + element.style.justifyContent = justify; + return element; + } + /// /// Get element current display value /// diff --git a/Documentation.meta b/Runtime/Scripts/UI.meta similarity index 77% rename from Documentation.meta rename to Runtime/Scripts/UI.meta index aeac946..ca4df2d 100644 --- a/Documentation.meta +++ b/Runtime/Scripts/UI.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f73a9b082dffd4e4f84882c2d35f3917 +guid: 2ba04e49bf26bb6a4971f1f19c59d136 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Editor/EATKEditor.cs b/Runtime/Scripts/UI/EATKEditor.cs similarity index 99% rename from Editor/EATKEditor.cs rename to Runtime/Scripts/UI/EATKEditor.cs index d216b12..28dd71b 100644 --- a/Editor/EATKEditor.cs +++ b/Runtime/Scripts/UI/EATKEditor.cs @@ -5,16 +5,19 @@ // -- Note: EATK is still currently being developed - API subject to change -- // ---------------------------------------------------------------------------- +#if UNITY_EDITOR + using System; using System.Collections.Generic; using System.Linq; -using instance.id.EATK.Extensions; + using JetBrains.Annotations; using UnityEditor; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.UIElements; using UnityEngine.UIElements.Experimental; +using instance.id.EATK.Extensions; namespace instance.id.EATK { @@ -1256,3 +1259,4 @@ private void Update() } } } +#endif diff --git a/Editor/EATKEditor.cs.meta b/Runtime/Scripts/UI/EATKEditor.cs.meta similarity index 100% rename from Editor/EATKEditor.cs.meta rename to Runtime/Scripts/UI/EATKEditor.cs.meta diff --git a/Editor/ElementData.meta b/Runtime/Scripts/UI/ElementData.meta similarity index 100% rename from Editor/ElementData.meta rename to Runtime/Scripts/UI/ElementData.meta diff --git a/Editor/ElementData/ObjectElementData.cs b/Runtime/Scripts/UI/ElementData/ObjectElementData.cs similarity index 100% rename from Editor/ElementData/ObjectElementData.cs rename to Runtime/Scripts/UI/ElementData/ObjectElementData.cs diff --git a/Editor/ElementData/ObjectElementData.cs.meta b/Runtime/Scripts/UI/ElementData/ObjectElementData.cs.meta similarity index 100% rename from Editor/ElementData/ObjectElementData.cs.meta rename to Runtime/Scripts/UI/ElementData/ObjectElementData.cs.meta diff --git a/Editor/Style.meta b/Runtime/Scripts/UI/Style.meta similarity index 100% rename from Editor/Style.meta rename to Runtime/Scripts/UI/Style.meta diff --git a/Editor/Style/EATKEditor.uss b/Runtime/Scripts/UI/Style/EATKEditor.uss similarity index 100% rename from Editor/Style/EATKEditor.uss rename to Runtime/Scripts/UI/Style/EATKEditor.uss diff --git a/Editor/Style/EATKEditor.uss.meta b/Runtime/Scripts/UI/Style/EATKEditor.uss.meta similarity index 100% rename from Editor/Style/EATKEditor.uss.meta rename to Runtime/Scripts/UI/Style/EATKEditor.uss.meta diff --git a/Editor/Style/Resources.meta b/Runtime/Scripts/UI/Style/Resources.meta similarity index 100% rename from Editor/Style/Resources.meta rename to Runtime/Scripts/UI/Style/Resources.meta diff --git a/Editor/Style/Resources/Fonts.meta b/Runtime/Scripts/UI/Style/Resources/Fonts.meta similarity index 100% rename from Editor/Style/Resources/Fonts.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Black.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Black.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Black.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Black.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Black.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Black.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Black.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Black.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-BlackIt.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BlackIt.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-BlackIt.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BlackIt.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-BlackIt.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BlackIt.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-BlackIt.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BlackIt.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Bold.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Bold.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Bold.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Bold.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Bold.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Bold.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Bold.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Bold.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-BoldIt.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BoldIt.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-BoldIt.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BoldIt.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-BoldIt.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BoldIt.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-BoldIt.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-BoldIt.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-It.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-It.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-It.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-It.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-It.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-It.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-It.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-It.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Light.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Light.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Light.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Light.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Light.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Light.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Light.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Light.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-LightIt.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-LightIt.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-LightIt.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-LightIt.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-LightIt.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-LightIt.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-LightIt.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-LightIt.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Medium.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Medium.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Medium.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Medium.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Medium.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Medium.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Medium.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Medium.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Regular.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Regular.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Regular.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Regular.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Regular.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Regular.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Regular.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Regular.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Semibold.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Semibold.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Semibold.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Semibold.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-Semibold.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Semibold.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-Semibold.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-Semibold.otf.meta diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf diff --git a/Editor/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf.meta b/Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf.meta similarity index 100% rename from Editor/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf.meta rename to Runtime/Scripts/UI/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf.meta diff --git a/Runtime/VisualElementEvents.meta b/Runtime/VisualElementEvents.meta new file mode 100644 index 0000000..43e9a53 --- /dev/null +++ b/Runtime/VisualElementEvents.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f5b7e38315f74c83a409ff5f0f25818f +timeCreated: 1627703253 \ No newline at end of file diff --git a/Runtime/VisualElementEvents/VisualElementEvents.cs b/Runtime/VisualElementEvents/VisualElementEvents.cs new file mode 100644 index 0000000..382f67c --- /dev/null +++ b/Runtime/VisualElementEvents/VisualElementEvents.cs @@ -0,0 +1,103 @@ +// ---------------------------------------------------------------------------- +// -- Project : https://github.com/instance-id/ElementAnimationToolkit -- +// -- instance.id 2020 | http://github.com/instance-id | http://instance.id -- +// ---------------------------------------------------------------------------- + +#if UNITY_EDITOR +using System; +using instance.id.EATK.Extensions; +using UnityEngine; +using UnityEngine.UIElements; + +namespace instance.id.EATK +{ + public static class VisualElementEvents + { + // -- Register Callback with element return ------------ + /// + /// RegisterCallback on element, as well as children, and return the element + /// + /// The target element in which to register the callback + /// The callback in which to register + /// Register child elements in addition to the target element + /// The event callback type in which to register + /// The target element + public static VisualElement RegisterCallback(this VisualElement element, EventCallback callback, bool includeChildren, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) + where TEventType : EventBase, new() + { + element.RegisterCallback(callback); + if (!includeChildren) return element; + var children = element.Query().Descendents().ToList(); + children.ForEach(x => x.RegisterCallback(callback)); + return element; + } + + /// + /// RegisterCallback on element, as well as children, and return the element + /// + /// The target element in which to register the callback + /// The callback in which to register + /// Register child elements in addition to the target element + /// The event callback type in which to register + /// The target element + public static void UnregisterCallback(this VisualElement element, EventCallback callback, bool includeChildren, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) + where TEventType : EventBase, new() + { + element.UnregisterCallback(callback); + if (!includeChildren) return; + var children = element.Query().Descendents().ToList(); + children.ForEach(x => x.UnregisterCallback(callback)); + } + + public static void MouseDownBackgroundColor(this T element, Color downColor, Color upColor = default) where T : VisualElement + { + var originalColor = element.resolvedStyle.backgroundColor; + + if (typeof(T) == typeof(Button)) + (element as Button).clickable.clickedWithEventInfo += (evt) => + { + if ((VisualElement)evt.currentTarget == element) + (element as Button).SetBackgroundColor(downColor); + }; + + else + element.RegisterCallback(evt => + { + if (evt.button == 0) + element.SetBackgroundColor(downColor); + }); + + element.RegisterCallback(evt => + { + if (evt.button == 0) + element.ExecuteIn(() => element.SetBackgroundColor(originalColor), 100); + }); + } + + public static void MouseDownImageColor(this T element, Color downColor, Color upColor = default) where T : VisualElement + { + var originalColor = element.resolvedStyle.backgroundColor; + + if (typeof(T) == typeof(Button)) + (element as Button).clickable.clickedWithEventInfo += (evt) => + { + if ((VisualElement)evt.currentTarget == element) + (element as Button).SetBackgroundImageColor(downColor); + }; + + else + element.RegisterCallback(evt => + { + if (evt.button == 0) + element.SetBackgroundImageColor(downColor); + }); + + element.RegisterCallback(evt => + { + if (evt.button == 0) + element.ExecuteIn(() => element.SetBackgroundImageColor(originalColor), 100); + }); + } + } +} +#endif diff --git a/Runtime/VisualElementEvents/VisualElementEvents.cs.meta b/Runtime/VisualElementEvents/VisualElementEvents.cs.meta new file mode 100644 index 0000000..058a17d --- /dev/null +++ b/Runtime/VisualElementEvents/VisualElementEvents.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 90b2cb673347bb8d5a0fe159731e31cf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/id.instance.elementanimationtoolkit.asmdef b/Runtime/id.instance.elementanimationtoolkit.asmdef index 67dce49..f94d91b 100644 --- a/Runtime/id.instance.elementanimationtoolkit.asmdef +++ b/Runtime/id.instance.elementanimationtoolkit.asmdef @@ -9,6 +9,12 @@ "precompiledReferences": [], "autoReferenced": true, "defineConstraints": [], - "versionDefines": [], + "versionDefines": [ + { + "name": "id.instance.extensions", + "expression": "", + "define": "USING_IDEXTENSIONS" + } + ], "noEngineReferences": false } \ No newline at end of file diff --git a/Samples/Scripts/Editor/ExampleComponentEditor.cs b/Samples/Scripts/Editor/ExampleComponentEditor.cs index b5111ae..b7eeca6 100644 --- a/Samples/Scripts/Editor/ExampleComponentEditor.cs +++ b/Samples/Scripts/Editor/ExampleComponentEditor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using instance.id.EATK.Examples; using instance.id.EATK.Extensions; using JetBrains.Annotations; using UnityEditor; @@ -8,7 +9,7 @@ using UnityEngine; using UnityEngine.UIElements; -namespace instance.id.EATK.Examples +namespace instance.id.EATK.Extensions { [CustomEditor(typeof(ExampleComponent))] public class ExampleComponentEditor : Editor @@ -220,21 +221,22 @@ private void DeferredExecution(GeometryChangedEvent evt) root.schedule.Execute(() => charVitalsLabel.AnimateColor(default, "#ff8000".FromHex(), 1000, Second)).StartingIn(600); root.schedule.Execute(() => charDetailLabel.AnimateColor(default, "#ff8000".FromHex(), 1000, First)).StartingIn(900); - void DoLabels() - { - var cascade = 100; - labelData.ForEach(l => - { - l.schedule.Execute(() => - { - l.AnimCharacterSequence( - "#BABABA".FromHex(), - "#2F569C".FromHex(), - 50, - 150); - }).StartingIn(cascade += 300); - }); - } + + // void DoLabels() + // { + // var cascade = 100; + // labelData.ForEach(l => + // { + // l.schedule.Execute(() => + // { + // l.AnimCharacterSequence( + // "#BABABA".FromHex(), + // "#2F569C".FromHex(), + // 50, + // 150); + // }).StartingIn(cascade += 300); + // }); + // } } private VisualElement headerContainer; @@ -242,9 +244,9 @@ void DoLabels() private IVisualElementScheduledItem headerHighlighter; private IVisualElementScheduledItem containerHighlighter; - int color1Duration = 500; - int color2Duration = 500; - int durationBuffer = 20; + private int color1Duration = 500; + private int color2Duration = 500; + // private int durationBuffer = 20; private void SetupHighlighter() { diff --git a/package.json b/package.json index b2f6165..1c80a50 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "name": "id.instance.elementanimationtoolkit", "displayName": "Element Animation Toolkit", "repositoryName": "Element Animation Toolkit", - "version": "0.1.9", + "version": "0.1.91", "description": "A collection of Unity UIElements standalone animations, new animated elements, and examples.", "type": "library", "unity": "2019.4",