# Coherent Labs: full documentation > Every page, as sections of at most ~1,600 characters separated by `---`. Each section starts > with a SOURCE tag naming its page URL and heading anchor; a section split into parts is headed `(i/n)`. --- [SOURCE: https://coherent-labs.com/] ## UI made simple (1/2) ## UI made simple The UI middleware that leverages web technologies to help you build intricate, high-performance interfaces. ## Product Gameface brings the power of web technologies to AAA game UI through a runtime engineered for performance and creative freedom. It helps teams move fast, integrate easily, and fine-tune every aspect of their UI with full visibility and control. Learn more ## Testimonials Coherent gave Gearbox a highly performant, tool-robust, time and cost effective solution—the next generation of UI tools. Having used other popular UI solutions, we find Coherent to be a lifesaver. We're actively spreading the good word. Michael Wardwell, Game Designer at Gearbox Software Our communication with the Coherent team was always great. Coherent GT demonstrates what we want in future UI engines. We'll work together again. Soo Min Park, CTO Bluehole Studio Inc. The Coherent team is knowledgeable and helpful. Their technology enabled us to create next generation UI The team at Nexon GT Co, Ltd Coherent offers the most fully-featured HTML + Javascript runtime for game UI that works across all major platforms Emil Anticevic, CTO and Co-founder of Counterplay Games For studios seeking a robust, off-the-shelf UI solution supported by a team of developers, Coherent's Gameface is an ideal choice. The UI team at Firaxis Games Another advantage of web technology is that it opens doors for our recruitment process, allowing us to draw on talent from outside of the game industry. We can now hire professionals with skills that prove immediately relevant. --- [SOURCE: https://coherent-labs.com/] ## UI made simple (2/2) Gary Richards, Game Director at Frontier Developments ## Our partners --- [SOURCE: https://coherent-labs.com/about-us/] ## UI made simple (1/2) ## UI made simple We partner with studios to turn ambitious UI ideas into seamless, high-performance experiences. At Coherent Labs, we believe creating game UIs should be as inspiring as the games themselves. That's why we build tools that make UI development powerful, simple, and fun - powered by modern web tech. What started as a small startup has grown into a trusted partner for leading game studios worldwide. Our flagship product, Coherent Gameface, is trusted across the industry to bring next-level interfaces to life. ## our values ### DESIRE TO LEARN Have the will to develop yourself both personally and professionally ### PASSION AND COMMITMENT You are encouraged to actively participate in task designing and bring in ideas ### ATTENTION TO DETAIL AND QUALITY Always strive for perfection but never at the expense of progress ### COURAGE AND CONFIDENCE Do not fear facing problems that nobody has encountered or solved before ### TECHNICAL EXCELLENCE We never stop looking for improvements and do not settle for "good" ### SHARED SUCCESS There is no success for us unless our users are successful with our tech ## Leadership ### George Petrov ##### CEO ##### george@coherent-labs.com ##### Tell us a fun fact about yourself ##### I like doing paper aeroplanes ##### What makes Coherent Labs special? ##### We're the only professional vendor for game UI middleware on the market. ### Dimitar Trendafilov ##### CTO ##### dimitar@coherent-labs.com ##### Tell us a fun fact about yourself --- [SOURCE: https://coherent-labs.com/about-us/] ## UI made simple (2/2) ##### I am a car enthusiast and I am making room in my life for doing rallies. ##### What makes Coherent Labs special? ##### We want to bring the fun into game development. ### Nick Vasilev ##### R&D Director ##### nick@coherent-labs.com ##### Tell us a fun fact about yourself ##### Once I missed 3 connecting flights in one trip and still got on time. ##### What makes Coherent Labs special? ##### We're the only professional vendor for game UI middleware on the market. ### Aleksandra Ivanov ##### Customer Success Director ##### alexandra@coherent-labs.com ##### Tell us a fun fact about yourself ##### I am a true makeup geek. ##### What makes Coherent Labs special? ##### Brainpower. I have never seen another group of people where every single member is extraordinarily smart and gifted. I guess that's what makes pushing technological and innovation boundaries an easy task for us. ### Annie Atanasova ##### Director of operations and finance ##### anelya.a@coherent-labs.com ##### Tell us a fun fact about yourself ##### I'm into extreme sports (like aerial acrobatics). ##### What makes Coherent Labs special? ##### I found out about Coherent Labs a few years ago. I recall being amazed by their determination and selflessness towards making game UI development a simple task. It's an absolute bliss being part of this. --- [SOURCE: https://coherent-labs.com/all-features-gameface/] ## Gameface All Features. (1/4) ## Gameface All Features. ### Workflow #### Iterate in seconds, not minutes Modify the UI while the game is running through our Developer tools and see the change immediately. Or, setup your game to automatically reload the UI anytime a file is changed. #### Use popular JavaScript libraries Use React + Redux, Preact, WebPack, jQuery, Anime.js and others and benefit from ever increasing knowledge and tools of the web world. ```js ReactDOM.render(

Hello, Gameface!

, document.getElementById('root') ); ``` #### Minimize scripting Use our declarative data binding to minimize the amount of code (especially boring code) you will need to synchronize the states of the game and the UI. ```html

``` #### Separate work concerns Work uninterrupted - anything UI related can be done from within Gameface without C++. The game's not ready yet? Test without the game in our test app. Data's not exposed? Mock it in JavaScript. Don't know how well your UI is working? Automate QA. ```js // Create some mock data engine.createJSmodel("player", { stats: { health: 55, mana: 33 } }); ``` #### More than standard compliance --- [SOURCE: https://coherent-labs.com/all-features-gameface/] ## Gameface All Features. (2/4) Gameface is a standard compliant HTML5 engine - we support **everything needed for game UI.** Even more, standard HTML5 lacks a few key features that modern game UI needs so we extend it with custom CSS and Javascript to do what you normally would have no way of doing. See the Pen [Simple Health bar](https://codepen.io/nikoladimitroff/pen/QJByZQ/) by Nikola Dimitroff ([@nikoladimitroff](https://codepen.io/nikoladimitroff)) on [CodePen](https://codepen.io). ### Visual Quality #### Variety of effects No visual effect is out of reach - apply filters and blend modes, 3D and 2D transform UI elements, use transparent videos for particle effects. Credits for the above [video](https://www.youtube.com/watch?v=RN8ss708b6M) go to [CyberWebFX](https://www.youtube.com/c/CyberWebFX) #### Scalable UI You don't need to guess what resolutions your players will be running on. Your UI will look as intended everywhere thanks to: - crisp font rendering at all resolutions - support for vector graphics (SVGs) - dynamically scaling elements based on the current viewport size #### All the image support you would ever need Want to use some platform-specific texture format (DDS, KTC, ASTC) or an image straight out of Photoshop (PSD)? You can do that.\ \ Want to load your UI textures by yourself? You can do that.\ \ Want to display your in-world camera capture in the UI (e.g. for a 3D player avatar)? You can do that. ### Integration #### Deep Unreal Engine and Unity integrations --- [SOURCE: https://coherent-labs.com/all-features-gameface/] ## Gameface All Features. (3/4) If you are using the amazing Unreal Engine or Unity, installation steps are as easy as 1-2-3. Our plugins for both engines will make you feel like our tech is a native part of the engine. - Custom components can be attached to any game object in your scene - Full scripting support for Blueprints / C# - A submenu in the editor gives you easy access to all of our features - Support for old and new versions of the both engines alike #### Amazing performance We are the fastest UI technology you can find anywhere and we have the data and testimonials to back it up. You’ve probably heard that HTML engines are usually slow - but Gameface was designed specifically for game UI and optimizes hard for it. For example, the UI above from the previous bullet, runs in under 1 ms on a standard PS4 (not PS4 Pro!). #### White box We are aware our tech doesn’t run in isolation from your game. For best performance, we give you control over all subsystems we can. - You control how the SDK allocates memory, loads resources, creates log files or reads input - Use out-of-the-box renderers for DirectX11, DirectX12, OpenGL, GLES2, GLES3, Metal, console-specific APIs or write your own - Run our parallel code on how many and whichever threads you like - the SDK never spawns threads on its own ```cpp void OnWorkAvailable(void*, cohtml::WorkType WorkType, cohtml::TaskFamilyId TaskFamily) { MyEngine::EnqueueWorkOnSomeThread([WorkType, TaskFamily]() { cohtml::Library::HintThreadUsage(WorkType); CohtmlLibrary->ExecuteWork(WorkType, cohtml::WEM_UntilQueueEmpty, TaskFamily); }); } ``` --- [SOURCE: https://coherent-labs.com/all-features-gameface/] ## Gameface All Features. (4/4) #### Clean API We write code so you don't have to and you only need an hour to understand how to use our API. - Setup is as easy 1-2-3 - Configure every setting you are interested in - Preserving backwards compatibility is a major goal - we rarely break it and when we do it's thoroughly described - The modular architecture allows you to turn off and on features depending on your needs. Feel free to switch off entire subsystems like video and HTTP support if you aren't going to use them. ```cpp // your game loop while (true) { // Update UI uiSystem->Advance(MyEngine::CurrentTime); auto frameId = uiScreen->Advance(MyEngine::CurrentTime); uiScreenRenderer->Paint(frameId); DrawUITextureOnScreen(); // Update engine simulation } ``` --- [SOURCE: https://coherent-labs.com/all-features-prysm/] ## Prysm All Features. (1/3) ## Prysm All Features. ### Workflow #### Use the tools you know and love There are no tools more loved by artists than Adobe's CC - and we want you to keep using them. Design and draw in Photoshop, create effects in After Effects, add motion in Animate. #### Add motion Use Adobe Animate's wide range of capabilities - animate colors, positions, sizes, masks, even the shapes themselves! #### Add interactions Through Prysm's plugin for Adobe Animate, add interactivity to your screens without code. - Declaratively specify how the game's data affects the UI. - Use the variety of events (player input, events from the game, UI changes on other elements, etc.) and actions to setup interactions like adding new UI widgets, switching between screens or sending data to the game. #### See your changes instantly There's no loading, baking or other preprocessing time - hit play and see how your UI looks immediately. ### Visual Quality #### Variety of effects No visual effect is out of reach - apply filters and blend modes, 3D and 2D transform UI elements, use transparent videos for particle effects. Credits for the above [video](https://www.youtube.com/watch?v=RN8ss708b6M) go to [CyberWebFX](https://www.youtube.com/c/CyberWebFX) #### Variety of effects No visual effect is out of reach - apply filters and blend modes, 3D and 2D transform UI elements, use transparent videos for particle effects. #### All the image support you would ever need --- [SOURCE: https://coherent-labs.com/all-features-prysm/] ## Prysm All Features. (2/3) Want to use some platform-specific texture format (DDS, KTC, ASTC) or an image straight out of Photoshop (PSD)? You can do that.\ \ Want to load your UI textures by yourself? You can do that.\ \ Want to display your in-world camera capture in the UI (e.g. for a 3D player avatar)? You can do that. ### Integration #### Deep Unreal Engine and Unity integrations If you are using the amazing Unreal Engine or Unity, installation steps are as easy as 1-2-3. Our plugins for both engines will make you feel like our tech is a native part of the engine. - Custom components can be attached to any game object in your scene - Full scripting support for Blueprints / C# - A submenu in the editor gives you easy access to all of our features - Support for old and new versions of the both engines alike #### Amazing performance We are the fastest UI technology you can find anywhere and we have the data and testimonials to back it up. You've probably heard that HTML engines are usually slow - but Gameface was designed specifically for game UI and optimizes hard for it. For example, the UI above from the previous bullet, runs in under 1 ms on a standard PS4 (not PS4 Pro!). #### White box We are aware our tech doesn't run in isolation from your game. For best performance, we give you control over all subsystems we can. --- [SOURCE: https://coherent-labs.com/all-features-prysm/] ## Prysm All Features. (3/3) - You control how the SDK allocates memory, loads resources, creates log files or reads input - Use out-of-the-box renderers for DirectX11, DirectX12, OpenGL, GLES2, GLES3, Metal, console-specific APIs or write your own - Run our parallel code on how many and whichever threads you like - the SDK never spawns threads on its own ```cpp void OnWorkAvailable(void*, cohtml::WorkType WorkType, cohtml::TaskFamilyId TaskFamily) { MyEngine::EnqueueWorkOnSomeThread([WorkType, TaskFamily]() { cohtml::Library::HintThreadUsage(WorkType); CohtmlLibrary->ExecuteWork(WorkType, cohtml::WEM_UntilQueueEmpty, TaskFamily); }); } ``` #### Clean API We write code so you don't have to and you only need an hour to understand how to use our API. - Setup is as easy 1-2-3 - Configure every setting you are interested in - Preserving backwards compatibility is a major goal - we rarely break it and when we do it's thoroughly described - The modular architecture allows you to turn off and on features depending on your needs. Feel free to switch off entire subsystems like video and HTTP support if you aren't going to use them. ```cpp // your game loop while (true) { // Update UI uiSystem->Advance(MyEngine::CurrentTime); auto frameId = uiScreen->Advance(MyEngine::CurrentTime); uiScreenRenderer->Paint(frameId); DrawUITextureOnScreen(); // Update engine simulation } ``` --- [SOURCE: https://coherent-labs.com/blog/] ## Powered by Coherent Labs (1/3) Search \[ ] Match all No results for You may want to try different keywords, checking for typos or adjusting your filters. Gameface UI: Adding a tutorial to the Menu UI 11/3/2025 UI tutorials Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide 8/28/2025 UI tutorials Gameface UI version 1.0.0 released 7/10/2025 News Strategic Interfaces: Gameface Joins the Civilization 6/17/2025 Case Studies Gameface E2E Released 5/27/2025 News Manager UI (part 5): Team Roster - Keyboard and gamepad navigation 4/17/2025 UI tutorials Manager UI (part 4): Keyboard and gamepad navigation 4/16/2025 UI tutorials Manager UI (part 3): Team roster UI screen 3/27/2025 UI tutorials Gameface UI Beta Released 3/11/2025 News Manager UI (part 2): Cross component interactions and utility components (Toast, Tooltip) 3/8/2025 UI tutorials Manager UI (part 1): Creating a draggable grid in Gameface 3/7/2025 UI tutorials 3D Map with UI markers - Adding interactions (part 2) 2/13/2025 UI tutorials 3D Map with UI markers - Project setup & displaying markers (part 1) 2/13/2025 UI tutorials Creating a camera tilt gauge 2/10/2025 UI tutorials How to create a Fish-eyed using a curved plane 2/9/2025 UI tutorials How to create different types of bars in Gameface 2/6/2025 UI tutorials Emoji support 1/28/2025 News Custom components with Shadow DOM-Now available in Gameface! 1/20/2025 News In-world hologram UI - In world inventory (Frontend) (Part 4) 1/9/2025 UI tutorials In-world hologram UI - In world inventory (Backend) (Part 3) 1/8/2025 UI tutorials --- [SOURCE: https://coherent-labs.com/blog/] ## Powered by Coherent Labs (2/3) Creating hexagonal skill tree 1/7/2025 UI tutorials In-world hologram UI - Showing an in world screen with a message (Part 2) 1/7/2025 UI tutorials In-world hologram UI - Showing a tooltip in game (Part 1) 12/17/2024 UI tutorials Creating a damage indicator 12/5/2024 UI tutorials Replicating the shadow menu from LA Noire 11/21/2024 UI tutorials Adding a UI into the world 11/8/2024 UI tutorials Recreating the separating texts in Forspoken 11/7/2024 UI tutorials Creating interactive game level selection menu 11/1/2024 UI tutorials Creating screen for character selection 10/29/2024 UI tutorials Multiplayer UI - Marketplace (Part 5) 10/11/2024 UI tutorials Multiplayer UI - Inventory (Part 4) 10/3/2024 UI tutorials Creating a dialogue tree for your game 10/1/2024 UI tutorials Making a 3D compass 9/11/2024 UI tutorials Nine slice modal 9/11/2024 UI tutorials Multiplayer UI - Create leaderboard (Part 3) 8/29/2024 UI tutorials Multiplayer UI - Two factor authentication login (Part 2) 8/6/2024 UI tutorials Multiplayer UI - Create login screen and friends list (Part 1) 7/31/2024 UI tutorials How to: Create action buttons for a mobile UI 7/24/2024 UI tutorials How to: Create a virtual joystick for a mobile UI 7/19/2024 UI tutorials Creating an interface for customizing character appearance 7/16/2024 UI tutorials Charts in Game UI 6/6/2024 UI tutorials Adding 3D items to a shop page 6/6/2024 UI tutorials Making chat with emojis in Gameface 5/30/2024 UI tutorials In-game highlights 5/16/2024 UI tutorials --- [SOURCE: https://coherent-labs.com/blog/] ## Powered by Coherent Labs (3/3) Skewed settings menu - Gamepad support 5/16/2024 UI tutorials Radial menus in Gameface 5/13/2024 UI tutorials 3D Subtitles 3/28/2024 UI tutorials Carousel with Perspective 3/28/2024 UI tutorials Custom CSS Cursor 3/28/2024 UI tutorials Hologram UI 3/28/2024 UI tutorials Skewed settings menu 3/28/2024 UI tutorials Making split screen UI with Gameface 3/28/2022 UI tutorials Creating nameplates and other dynamic onscreen elements 3/8/2022 UI tutorials Unit 2 Games - realizing their vision for UGC games with the help of CL tech 8/1/2019 News Introducing Vulkan support in the Coherent Technology 7/26/2019 Software development Say hi, new coherent brand! 6/6/2019 News Incoming Renoir backend API changes 2/6/2019 Software development Gameface 1.0 released! 12/7/2018 releases Prysm 1.0 released! 12/7/2018 releases HTML is the best alternative to Scaleform 11/26/2018 News Taking the Next Step: A New Brand Identity for Coherent Labs 9/10/2018 Inside coherent labs Development process in Coherent Labs 6/29/2018 Workflow Introducing Coherent Console Fonts 5/30/2018 Design and animation What you need to know about Hummingbird's support for Nintendo Switch 4/24/2018 News On the road to HTML5 7/28/2017 News --- [SOURCE: https://coherent-labs.com/blog/casestudies/firaxis-case-study/] ## Strategic Interfaces: Gameface Joins the Civilization (1/3) ## Strategic Interfaces: Gameface Joins the Civilization case studies 6/17/2025 Coherent Labs 1. What were the main UI goals that Coherent enabled you to achieve? What do you see as Coherent’s main benefit for your needs? 2. Can you share any specific insight about the impact Coherent had on your game’s UI performance? 3. Would you recommend Coherent to other studios and why? 4. How do you see your project evolving with time? Firaxis Games, the legendary studio behind the Civilization franchise, delivered another milestone in grand strategy with the release of Civilization VII earlier this year. Building on the series’ rich legacy, the game pushes boundaries with new systems, refined visuals, and a modernized user experience. At Coherent Labs, we’re proud to have supported this vision through our UI middleware, Coherent Gameface, which powers the game’s responsive UI across all the platforms. To offer a glimpse into how Gameface contributed behind the scenes, we reached out to Firaxis’ UI team for a short Q\&A on their experience integrating our tech into their custom AAA engine. #### What were the main UI goals that Coherent enabled you to achieve? What do you see as Coherent’s main benefit for your needs? --- [SOURCE: https://coherent-labs.com/blog/casestudies/firaxis-case-study/] ## Strategic Interfaces: Gameface Joins the Civilization (2/3) A major goal of Civilization VII was delivering a polished, unified UI experience simultaneously across PC storefronts, consoles, and handheld devices. Coherent’s Gameface enabled us to efficiently create a consistent interface tailored for multiple platforms, significantly reducing development overhead and ensuring a seamless, high-quality user experience regardless of device. #### Can you share any specific insight about the impact Coherent had on your game’s UI performance? With Coherent Gameface, we were able to deliver a stable and responsive UI across all platforms. This was made possible by Gameface’s flexibility in supporting various computing architectures, whether single-threaded or multi-threaded. Additionally, integration with Chrome’s Inspector allowed us to quickly identify and resolve performance issues early in development using the built-in profiler and heap analyzer. #### Would you recommend Coherent to other studios and why? Yes, for studios seeking a robust, off-the-shelf UI solution supported by a team of developers, Coherent’s Gameface is an ideal choice. Gameface’s implementation of open web standards such as HTML5 and CSS accelerates the onboarding for developers. We found the comprehensive documentation, tutorials, and flexible rendering API helped to streamline our integration into our custom AAA game engine. #### How do you see your project evolving with time? --- [SOURCE: https://coherent-labs.com/blog/casestudies/firaxis-case-study/] ## Strategic Interfaces: Gameface Joins the Civilization (3/3) Looking ahead, we’re excited about Coherent Gameface’s roadmap, particularly its increasing compatibility with modern frontend frameworks such as SolidJS. We are also excited to see what our modding community will be able to develop and run on this Gameface-based UI system. With Civilization VII now thriving in players’ hands, the road ahead looks just as exciting: Firaxis upcoming Update 1.2.2 packs in Steam Workshop support, Large & Huge map types, new advanced setup options, and another round of UI polish. We’re thrilled to see how both Firaxis and the community leverage our adaptable UI framework- right as we at Coherent expand keep working on our exciting roadmap for the year. Stay tuned for the more behind-the-scenes stories as our journey unfolds! ## On this page --- [SOURCE: https://coherent-labs.com/blog/design-and-animation/introducing-coherent-console-fonts/] ## Introducing Coherent Console Fonts (1/3) ## Introducing Coherent Console Fonts design-and-animation 5/30/2018 Alexandra Ivanov ##### As most of you know, icon fonts are font files that are filled with icons and graphs instead of letters or numbers. Many of you are using some type of similar fonts in their daily work-related tasks. Icon fonts are not just a modern way of using iconography bur rather a way to communicate information in a more efficient way to the user. That’s why we are happy to introduce to you one of our new features in Hummingbird – The Coherent Console Fonts. Coherent Console Fonts is a bundle of fonts created especially with the purpose to make using control signification in the games much easier for the designers and developers. Each one of the Coherent Fonts represents the main control buttons from the console’s controller. There are three available fonts – one for each of the biggest names on the market – PlayStation, Xbox & Nintendo Switch. Coherent Console Fonts save you time from creating custom control icons for every different project. You’re able to apply different text effects on them every time you need to spice up the look. Another great advantage is that the size of Coherent Console Fonts can be changed in a few minutes, and there is zero need for Photoshop to do that. Our icon font characters are vectors – meaning they look well even in high pixel-density displays. At last but not least, when using Coherent Console Fonts, your files will be lighter in size resulting in faster UI loading, which can’t be achieved when using regular SVG or PNG icons. ##### --- [SOURCE: https://coherent-labs.com/blog/design-and-animation/introducing-coherent-console-fonts/] ## Introducing Coherent Console Fonts (2/3) As most of you know, icon fonts are font files that are filled with icons and graphs instead of letters or numbers. Many of you are using some type of similar fonts in their daily work-related tasks. Icon fonts are not just a modern way of using iconography bur rather a way to communicate information in a more efficient way to the user. That’s why we are happy to introduce to you one of our new features in Hummingbird – The Coherent Console Fonts. Coherent Console Fonts is a bundle of fonts created especially with the purpose to make using control signification in the games much easier for the designers and developers. Each one of the Coherent Fonts represents the main control buttons from the console’s controller. There are three available fonts – one for each of the biggest names on the market – PlayStation, Xbox & Nintendo Switch. Coherent Console Fonts save you time from creating custom control icons for every different project. You’re able to apply different text effects on them every time you need to spice up the look. Another great advantage is that the size of Coherent Console Fonts can be changed in a few minutes, and there is zero need for Photoshop to do that. Our icon font characters are vectors – meaning they look well even in high pixel-density displays. At last but not least, when using Coherent Console Fonts, your files will be lighter in size resulting in faster UI loading, which can’t be achieved when using regular SVG or PNG icons. ##### To install Coherent Console Fonts on MacOS, open Font Book, then drag and drop the files into the app. You’re done. --- [SOURCE: https://coherent-labs.com/blog/design-and-animation/introducing-coherent-console-fonts/] ## Introducing Coherent Console Fonts (3/3) ## On this page --- [SOURCE: https://coherent-labs.com/blog/inside-coherent-labs/taking-the-next-step-а-new-brand-identity-for-coherent-labs/] ## Taking the Next Step: A New Brand Identity for Coherent Labs ## Taking the Next Step: A New Brand Identity for Coherent Labs inside-coherent-labs 9/10/2018 Alexandra Ivanov 1. The initial goal 2. Who are we today ##### --- [SOURCE: https://coherent-labs.com/blog/inside-coherent-labs/taking-the-next-step-а-new-brand-identity-for-coherent-labs/#the-initial-goal] ## Taking the Next Step: A New Brand Identity for Coherent Labs: The initial goal Back in 2012, four developers with years of experience in the gaming industry came up with an innovative idea for game UI creation. Through the use of modern web technologies like HTML5, they wanted to help both designers and developers make stunning and powerful interfaces, without limiting the game’s creativity and performance. Four generations of Coherent Labs products later, we can safely say that the initial goal has been achieved! In the beginning, the company’s brand identity was assembled bit by bit and using the resources available at hand. In fact, almost all aspects of our identity were created by friends, including our logo. The idea for it was pretty simple – the name in a thick, techy font. The website was fairly modest and we hardly had any presence on social networks. At the time, all of the efforts went into making the most advanced software for game UI development, while the brand and visual identity were put on the back burner. ##### --- [SOURCE: https://coherent-labs.com/blog/inside-coherent-labs/taking-the-next-step-а-new-brand-identity-for-coherent-labs/#who-are-we-today] ## Taking the Next Step: A New Brand Identity for Coherent Labs: Who are we today As time passed, Coherent Labs grew from just a few employees to a team of over 50 motivated people! Today, we are proud to offer the best UI solution and be a reliable partner of more than 200 game studios. Hard work and customer feedback helped us grow from a small tech startup to a mature company that teams up with the leaders in the game industry and plays a role in some of the most popular games made in recent history – like PUBG and Sea of Thieves. We wanted to mark this important transition and announce that we are working on a fresh new brand identity! We have many exciting news and updates coming up as we want to make you a part of the process and have your valuable feedback. If you want to stay up to date, follow us on social media. ## We are ready for takeoff! See you soon in our new virtual home ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/] ## Custom components with Shadow DOM-Now available in Gameface! ## Custom components with Shadow DOM-Now available in Gameface! news 1/20/2025 Martin Bozhilov 1. Overview 2. Usage 3. Project setup 4. Inventory component 1. Adding markup to the shadow root 2. Component Logic 5. The rest of the components 1. Inventory item 2. Inventory weapon 3. Inventory consumable 6. Bringing it all together 7. In conclusion 8. Sample location Learn how to create game inventory with the newly added `Shadow DOM` feature in Gameface! --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#overview] ## Custom components with Shadow DOM-Now available in Gameface!: Overview With version 1.61, Gameface now has [Shadow DOM ](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM)support for [custom elements ](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements), bringing a robust way to encapsulate styles and markup. Shadow DOM is a core feature of the modern Web Components standard, providing a mechanism to attach a hidden DOM tree to an element—effectively shielding the element’s structure, style, and behavior from the rest of the page. This encapsulation ensures that the component’s internal layout and styles are self-contained and do not leak or clash with other parts of the application. --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#usage] ## Custom components with Shadow DOM-Now available in Gameface!: Usage To showcase the power and usability of the Shadow DOM, we will create a simple inventory menu with custom elements. In this inventory, players will be able to: - Open/close the inventory - View an item’s description - Equip or consume an item The entire UI will be built with custom elements, using only vanilla JavaScript features. --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#project-setup] ## Custom components with Shadow DOM-Now available in Gameface!: Project setup (1/2) For this project, we are going to utilize [data binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/). We’ll also mock game data with a model containing all the necessary information for the inventory. **Click to reveal model** The inventory items will have an id, name and path to an image. Additionally, we wil define a field with the number of available inventory slots. --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#project-setup] ## Custom components with Shadow DOM-Now available in Gameface!: Project setup (2/2) ```js (() => { engine.createJSModel('InventoryItems', { list: { 'icon_Axe_1_Small': { typeId: 0, name: 'Axe 1', image: './images/icon_Axe_1_Small.png' }, 'icon_Axe_2_Small': { typeId: 0, name: 'Axe 2', image: './images/icon_Axe_2_Small.png' }, 'icon_Axe_3_Small': { typeId: 0, name: 'Axe 3', image: './images/icon_Axe_3_Small.png' }, 'icon_Book_Small': { typeId: 1, quantity: 8, name: 'Book', image: './images/icon_Book_Small.png' }, 'icon_Bracelet_Small': { typeId: 0, name: 'Bracelet', image: './images/icon_Bracelet_Small.png' }, 'icon_Dagger_Small': { typeId: 0, name: 'Dagger', image: './images/icon_Dagger_Small.png' }, 'icon_HealthPotion_Small': { typeId: 1, quantity: 10, name: 'HealthPotion', image: './images/icon_HealthPotion_Small.png' }, 'icon_PoisonVial_Small': { typeId: 1, quantity: 2, name: 'PoisonVial', image: './images/icon_PoisonVial_Small.png' }, 'icon_Ring1_Small': { typeId: 0, quantity: 5, name: 'Ring 1', image: './images/icon_Ring1_Small.png' }, 'icon_Ring2_Small': { typeId: 1, quantity: 5, name: 'Ring 2', image: './images/icon_Ring2_Small.png' }, 'icon_Scroll1_Small': { typeId: 1, quantity: 5, name: 'Scroll 1', image: './images/icon_Scroll1_Small.png' }, 'icon_Scroll2_Small': { typeId: 1, quantity: 5, name: 'Scroll 2', image: './images/icon_Scroll2_Small.png' }, }, inventorySpace: 24, }); })(); ``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#inventory-component] ## Custom components with Shadow DOM-Now available in Gameface!: Inventory component (1/4) We’ll start with the main UI component: **the inventory component**. In your project, create a folder named `game-inventory` and place a script.js file inside it. We’ll use a dedicated folder for each component to keep the project organized. Let’s initialize the `game-inventory` component: ```js class GameInventory extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.state = { display: false }; } connectedCallback() {} customElements.define("game-inventory", GameInventory); ``` To enable the Shadow DOM, we must attach the [shadow root ](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot)to our custom element. #### Adding markup to the shadow root There are several ways to add HTML to your custom elements. We’ll use a straightforward approach: keep the HTML and styles in the script as a string, then append them to the Shadow DOM after initialization. Let’s create an `inventoryTemplate` variable and assign it the element’s markup. --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#inventory-component] ## Custom components with Shadow DOM-Now available in Gameface!: Inventory component (2/4) ```js let slots = ""; for (let i = 0; i < InventoryItems.inventorySpace; i++) { slots += '
'; } const inventoryTemplate = `
Left click on an item to show details. Right click on an item to use/equip.
${slots}
` ``` Now in the `connectedCallback` method—which is called when the component is added to the DOM—we’ll append the template to the Shadow DOM: ```js connectedCallback() { this.shadowRoot.innerHTML = inventoryTemplate; this.onTemplateLoaded(); } ``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#inventory-component] ## Custom components with Shadow DOM-Now available in Gameface!: Inventory component (3/4) We’ve also added a `onTemplateLoaded` method, where we will initialize the component’s logic after the HTML has been attached. That’s it for the element’s markup! Thanks to the Shadow DOM, the component’s styles and markup are now encapsulated inside the game-inventory element. #### Component Logic To complete the inventory we’ll need to add the following methods. - `addInventoryItems` - adds the items from the `InventoryItems` model to the Inventory - `addInventoryItem` - adds a single item - `addItemAt` - adds an item at a specific slot - `findFreeSocketId` - finds the id of a socket that has no item in it - `isSocketFree` - checks if a socket has an item in it - `toggle` - shows/hiddes the inventory - `onTemplateLoaded` - Inits inventory logic **Click to view source** --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#inventory-component] ## Custom components with Shadow DOM-Now available in Gameface!: Inventory component (4/4) ```js /** * Adds the inventory items to the inventory. * InventoryItems is the data binding model registered in the global * namespace by Gameface. */ addInventoryItems() { const itemsIds = Object.keys(InventoryItems.list); for (let itemId of itemsIds) { this.addInventoryItem(InventoryItems.list[itemId], itemId); } } /** * Creates an inventory item instance and adds it into an available slot * in the inventory. * @param {Object} item - the inventory item from the model (InventoryItems) * @param {string} itemId - the item's identifier * @param {number} [socketId=0] - the inventory socket's id into which the * item should added. The default is 0 - this will add it in the next free socket. */ addInventoryItem(item, itemId, socketId = 0) { let WrappedComponent = 'inventory-consumable'; if (item.typeId === 0) WrappedComponent = 'inventory-weapon'; const inventoryItem = document.createElement('inventory-item'); inventoryItem.socket = socketId; inventoryItem.itemid = itemId; inventoryItem.imageurl = `{{InventoryItems.list.${itemId}.image}}`; inventoryItem.description = item.name; inventoryItem.WrappedComponent = WrappedComponent; this.addItemAt(inventoryItem, socketId); } /** * Adds an inventory item instance to a given inventory socket. * @param {Object} item - the inventory item from the model (InventoryItems) * @param {number} socketId - the inventory socket's id into which the * item should added */ addItemAt(item, socketId) { const itemSlotElements = this.shadowRoot.querySelectorAll('.inventory-slot'); if (!this.isSocketFree(socketId)) socketId = this.findFreeSocketId(); this.itemSlots[socketId] = socketId; itemSlotElements[socketId].appendChild(item); } /** * Finds the first free inventory socket. * @returns {number} - the id of the socket. */ findFreeSocketId() { for (let i = 0; i < this.itemSlots.length; i++) { if (this.itemSlots[i] === undefined) return i; } } /** * Checks if an inventory socket with a given id is free. * @returns {boolean} - true if it's free, false if it's not */ isSocketFree(socketId) { return this.itemSlots[socketId] === undefined; } /** * Toggles the inventory instance. */ toggle() { this.state.display = !this.state.display; this.classList.toggle('hidden', !this.state.display); } /** * Called when the component's template was loaded. */ onTemplateLoaded() { this.itemSlots = new Array(slots.length); this.addInventoryItems(); this.classList.toggle('hidden', !this.state.display); } ``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#the-rest-of-the-components] ## Custom components with Shadow DOM-Now available in Gameface!: The rest of the components (1/6) We’ll create the other custom elements in this UI using the same approach: defining a template string and appending it to the element’s Shadow DOM (where applicable). #### Inventory item The inventory item will have a details panel that opens on click. Inventory items will of two types - consumable and weapon. Where the consumable item will have quantity and the weapon - won’t. We’ll be making new components for the weapon and consumable that will be wrapped in an `inventory-item` in order to share functionality. The `inventory-item` will populate itself with either a weapon or a consumable depending on the type of the current item. **Note**: The `inventory-item` component doesn’t contain its own markup since it acts solely as a functionality wrapper, so we won’t use the Shadow DOM there. **Click to reveal component’s implementation** We will define the following methods: - `setup` - Will collect the item’s info and create the child component depending on it’s category - `createModal` - Creates the modal element that will show the details of each inventory item - `showDetailsModal` - Creates the modal and appends it to the page with the correct item’s information --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#the-rest-of-the-components] ## Custom components with Shadow DOM-Now available in Gameface!: The rest of the components (2/6) ```js class InventoryItem extends HTMLElement { constructor() { super(); this.onClick = () => this.showDetailsModal(); } connectedCallback() { this.classList.add('inventory-item'); this.details = document.getElementById("details-container"); this.setup(); } setup() { const wrappedComponent = document.createElement(this.WrappedComponent); wrappedComponent.itemid = this.itemid; wrappedComponent.imageurl = this.imageurl; wrappedComponent.description = this.description; wrappedComponent.onClick = this.onClick; this.appendChild(wrappedComponent); } /** * Creates modal containing the item's information * @returns {HTMLElement} modal */ createModal() { const modal = document.createElement('div'); modal.className = 'modal'; const header = document.createElement('div'); header.className = 'modal-header'; header.textContent = this.description; modal.appendChild(header); const content = document.createElement('div'); content.className = 'modal-content'; modal.appendChild(content); const imageItem = document.createElement('div'); imageItem.style.backgroundImage = `url(${InventoryItems.list[this.itemid].image})`; imageItem.className = 'info-image'; content.appendChild(imageItem); const itemDescription = document.createElement('div'); itemDescription.textContent = 'Item description'; content.appendChild(itemDescription); const closeBtn = document.createElement('div'); closeBtn.className = 'close-x'; closeBtn.addEventListener('click', () => modal.classList.remove('visible')) modal.appendChild(closeBtn) return modal; } /** * Creates and appends a modal element to the detail's container */ showDetailsModal() { const modal = this.createModal(); const detailsContainer = document.getElementById('details-container'); detailsContainer.innerHTML = ''; detailsContainer.appendChild(modal); modal.classList.add('visible'); } } customElements.define('inventory-item', InventoryItem); ``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#the-rest-of-the-components] ## Custom components with Shadow DOM-Now available in Gameface!: The rest of the components (3/6) #### Inventory weapon The weapon component is going to have logic for setting up the content - the image and the description and a method for equipping. We will set up the content and attach the event listeners in the `connectedCallback`. Apart from that we’ll also need to call `engine.synchronizeModels()` to make sure that the data binding attributes are updated. We will define the following methods: - `setupContent` - Sets the html content of the weapon item and sets the data-binding attributes. - `equip` - Equips the weapon by setting its `equipped` property to `true`. Remember, because elements in the Shadow DOM are scoped to that shadow root, we must query them with `this.shadowRoot.querySelector` instead of the global `document.querySelector`. --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#the-rest-of-the-components] ## Custom components with Shadow DOM-Now available in Gameface!: The rest of the components (4/6) ```js const weaponTemplate = `
`; class InventoryWeapon extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.onClickBound = (e) => { if (e.button === 2) return this.equip(); // on click is assigned in InventoryItem this.onClick(); }; } connectedCallback() { this.shadowRoot.innerHTML = weaponTemplate; this.setupContent(); this.addEventListener('mousedown', this.onClickBound); engine.synchronizeModels(); } /** * Sets the html content of the consumable item and sets the data binding attributes. */ setupContent() { this.classList.add('inventory-weapon'); this.shadowRoot.querySelector('.image') .setAttribute('data-bind-style-background-image-url', this.imageurl); this.shadowRoot.querySelector('.weapon') .setAttribute('data-bind-class-toggle', `disabled:{{InventoryItems.list.${this.itemid}.equipped}} == true`); } /** * Equips the weapon by setting its equipped property to true. */ equip() { if (InventoryItems.list[this.itemid].equipped) return; InventoryItems.list[this.itemid].equipped = true; engine.updateWholeModel(InventoryItems); engine.synchronizeModels(); } } customElements.define('inventory-weapon', InventoryWeapon); ``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#the-rest-of-the-components] ## Custom components with Shadow DOM-Now available in Gameface!: The rest of the components (5/6) #### Inventory consumable Similar to the weapon component, the consumable component is also an inventory item, but the right-click interaction uses one of the consumables instead of equipping it. Its template differs slightly by including a quantity badge. We will define the following methods: - `setupContent` - Sets the HTML content of the consumable item and sets the data binding attributes. - `use` - Decreases the consumable’s quantity by 1 when used. **Click to reveal component’s implementation** --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#the-rest-of-the-components] ## Custom components with Shadow DOM-Now available in Gameface!: The rest of the components (6/6) ```js const consumableTemplate = `
`; class InventoryConsumable extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.onClickBound = (e) => { if (InventoryItems.list[this.itemid].quantity === 0) return; // right mouse button if (e.button === 2) return this.use(); this.onClick(); }; } connectedCallback() { this.shadowRoot.innerHTML = consumableTemplate; this.setupContent(); this.addEventListener('mousedown', this.onClickBound); engine.synchronizeModels(); } /** * Sets the html content of the consumable item and sets the data binding attributes. */ setupContent() { this.classList.add('inventory-consumable'); this.shadowRoot.querySelector('.image').setAttribute('data-bind-style-background-image-url', this.imageurl); this.shadowRoot.querySelector('.consumable').setAttribute('data-bind-class-toggle', `disabled:{{InventoryItems.list.${this.itemid}.quantity}} == 0`); this.shadowRoot.querySelector('.quantity').setAttribute('data-bind-value', `{{InventoryItems.list.${this.itemid}.quantity}}`); } /** * Uses one of the consumable items by decreasing its quantity by 1. */ use() { InventoryItems.list[this.itemid].quantity -= 1; engine.updateWholeModel(InventoryItems); engine.synchronizeModels(); } } customElements.define('inventory-consumable', InventoryConsumable); ``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#bringing-it-all-together] ## Custom components with Shadow DOM-Now available in Gameface!: Bringing it all together (1/4) After setting up our custom components, the last step is to bring everything together. First, create an `index.html` file and import the `cohtml.js` file, the previously created model, and all your custom elements: ```html Game inventory ``` Next, let’s create a button to toggle the inventory, as well as add our `game-inventory` element—the main entry point for this project’s logic: ```html
Open Inventory
``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#bringing-it-all-together] ## Custom components with Shadow DOM-Now available in Gameface!: Bringing it all together (2/4) Finally, add some basic styles for the toggle button and the modal element: --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#bringing-it-all-together] ## Custom components with Shadow DOM-Now available in Gameface!: Bringing it all together (3/4) ```css body { margin: 0; background-color: gray; } .hidden { display: none; } .button { color: #ffffff; width: 261px; height: 53px; cursor: pointer; background-size: contain; background-repeat: no-repeat no-repeat; background-image: url(./images/btn_MainMenu_normal.png); text-align: center; font-size: 17px; line-height: 46px; } .button:hover { background-image: url(./images/btn_MainMenu_active.png); } .ui { display: flex; flex-direction: row; } #details-container { margin-left: 20px; } /* ---------------------------------- */ .modal { background-image: url('./images/bg_MainMenu.png'); background-size: contain; background-repeat: no-repeat; padding: 25px; margin-top: 10px; display: none; flex-direction: column; align-items: center; position: relative; color: #ffffff; width: 300px; height: 250px; } .modal.visible { display: flex; } .modal-header { font-weight: bold; margin-bottom: 15px; } .info-image { width: 120px; height: 120px; background-size: contain; background-repeat: no-repeat; background-position: center; margin-bottom: 10px; } .close-x { position: absolute; top: 0; right: 10px; width: 35px; height: 35px; cursor: pointer; background-image: url('./images/btn_Close.png'); background-size: contain; background-repeat: no-repeat; border: none; background-color: transparent; } .close-x:hover { background-color: transparent; background-image: url('./images/btn_Close2.png'); } ``` --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#bringing-it-all-together] ## Custom components with Shadow DOM-Now available in Gameface!: Bringing it all together (4/4) With that, our custom-elements-based game inventory UI is finished! --- [SOURCE: https://coherent-labs.com/blog/news/custom-components-with-shadow-dom/#in-conclusion] ## Custom components with Shadow DOM-Now available in Gameface!: In conclusion By leveraging custom elements and the Shadow DOM, building modular UI components becomes both simpler and more robust. The level of encapsulation and reusability custom elements provide means you can confidently scale your project and reuse all elements without worrying about conflicting styles or tangled logic. #### Sample location You can find the complete sample source within the `${Gameface package}/Samples/uiresources/ComponentsWithShadowDOM` directory. ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/e2e-testing-framework/] ## Gameface E2E Released ## Gameface E2E Released news 5/27/2025 Kaloyan Geshev 1. What is Gameface E2E? 2. Features of Gameface E2E 3. Getting Started with Gameface E2E 4. Writing Tests 5. Running the tests 6. Conclusion We are excited to announce the release of our new end-to-end (E2E) testing framework for Gameface. This powerful tool is designed to streamline the testing process for your game UI, ensuring that everything works as expected before you launch. --- [SOURCE: https://coherent-labs.com/blog/news/e2e-testing-framework/#what-is-gameface-e2e] ## Gameface E2E Released: What is Gameface E2E? Gameface E2E is a framework designed for creating and running end-to-end tests for your game UI within Gameface. It simplifies the automation of UI testing, ensuring your interface functions correctly in various scenarios. Built on the `DevTools` protocol, Gameface E2E integrates seamlessly with Gameface, allowing you to incorporate it into your development workflow effortlessly and begin testing your UI immediately. --- [SOURCE: https://coherent-labs.com/blog/news/e2e-testing-framework/#features-of-gameface-e2e] ## Gameface E2E Released: Features of Gameface E2E Gameface E2E offers a variety of features to help you efficiently test your game UI: - **Automated Testing**: Simulate user interactions like clicking, typing, scrolling, and menu navigation to validate your UI’s behavior in different situations. - **Parallel Test Execution**: Run multiple tests concurrently to accelerate the testing process, especially beneficial for projects with extensive UI components. - **Intuitive API**: The framework provides a straightforward and developer-friendly API, enabling quick test creation without requiring deep technical expertise. - **Customizable Configuration**: Easily set up and tailor the framework to meet your specific testing requirements. - **Mock Data Testing**: Test your UI with mocked game data to ensure it performs correctly under various input scenarios. --- [SOURCE: https://coherent-labs.com/blog/news/e2e-testing-framework/#getting-started-with-gameface-e2e] ## Gameface E2E Released: Getting Started with Gameface E2E The Gameface E2E testing framework is available on [npm ](https://www.npmjs.com/package/gameface-e2e). You can install it using the following command: ```shell npm install gameface-e2e --save-dev ``` Alternatively, you can install it globally: ```shell npm install gameface-e2e -g ``` Once installed, you can begin creating tests using the framework’s API. Detailed documentation and API references are available [here ](https://frontend-tools.coherent-labs.com/e2e/getting-started/). To help you get started, the package includes a collection of example tests located in the `examples` folder. --- [SOURCE: https://coherent-labs.com/blog/news/e2e-testing-framework/#writing-tests] ## Gameface E2E Released: Writing Tests Tests are written in `.spec` files using the framework’s API and the [Mocha ](https://mochajs.org/)syntax. Here is an example of a test file: ```javascript describe("Test my UI", () => { it("Should display the correct text", async () => { const element = await gf.get('.my-element'); const text = await element.text(); assert.equal(text, 'Hello, World!'); }); it("Should update the text when clicked", async () => { const btn = await gf.get('.my-button'); await btn.click(); const element = await gf.get('.my-element'); const text = await element.text(); assert.equal(text, 'Hello, Gameface!'); }); }); ``` --- [SOURCE: https://coherent-labs.com/blog/news/e2e-testing-framework/#running-the-tests] ## Gameface E2E Released: Running the tests To run your tests, you can use the following command: ```shell npx gameface-e2e --gamefacePath=${PATH_TO_PLAYER_EXE} --tests=${PATH_TO_SPEC_FILES} ``` or if you have installed the framework globally: ```shell gameface-e2e --gamefacePath=${PATH_TO_PLAYER_EXE} --tests=${PATH_TO_SPEC_FILES} ``` Where `${PATH_TO_PLAYER_EXE}` is the path to the Gameface player executable and `${PATH_TO_SPEC_FILES}` is the path to your test files. To simplify the command, you can create a configuration file in the root directory of your project. Name the file `gameface-e2e.config.js` and include the following content: ```javascript module.exports = { tests: "examples/**/*.spec.js", gamefacePath: "C:/Gameface/Player/Player.exe" } ``` After setting up the configuration file, you can simply execute the following command to run your tests: ```shell npx gameface-e2e ``` --- [SOURCE: https://coherent-labs.com/blog/news/e2e-testing-framework/#conclusion] ## Gameface E2E Released: Conclusion The Gameface E2E testing framework is a powerful tool that can help you ensure the quality and reliability of your game UI. With its simple API, automated testing capabilities, and seamless integration with Gameface, you can easily write and run tests to verify that your UI behaves as expected. You can find the full documentation of the framework and its API [here ](https://frontend-tools.coherent-labs.com/e2e/getting-started/). ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/] ## Emoji support ## Emoji support news 1/28/2025 Kaloyan Geshev 1. Overview 2. Usage 1. Importing an emoji font 2. Updating the emoji panel button 3. Making the emojis panel to work with the font 4. Adding emoji to the message input 5. Refactoring the server 3. Conclusion 4. Where you can find the enhanced sample? --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#overview] ## Emoji support: Overview With version 1.61, Gameface adds support for certain types of emoji fonts. Emojis and colored text glyphs can enhance the visual fidelity of any Web component that includes displaying text. Gameface can now load fonts that contain emoji characters and use them in any text context. Gameface officially supports the following fonts: - [EmojiTwoCOLRv0.ttf](https://github.com/Emoji-COLRv0/Emoji-COLRv0/blob/main/fonts/EmojiTwoCOLRv0.ttf) - [OpenMojiCOLRv0.ttf](https://github.com/Emoji-COLRv0/Emoji-COLRv0/blob/main/fonts/OpenMojiCOLRv0.ttf) - [TwemojiCOLRv0.ttf](https://github.com/Emoji-COLRv0/Emoji-COLRv0/blob/main/fonts/TwemojiCOLRv0.ttf) - [Segoe UI Emoji](https://learn.microsoft.com/en-us/typography/font-list/segoe-ui-emoji) If you require a different emoji font or want to create a custom one, the font file must be in the `COLRV0` format, as curently Gameface supports emoji fonts only in this format. For more details, check out the [Emoji Support ](https://docs.coherent-labs.com/cpp-gameface/content_development/emojisupport/)section of our documentation. --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#usage] ## Emoji support: Usage (1/7) To showcase the functionality of emoji fonts, we’ll walk you through updating our Chat emojis sample from the UI tutorials. The enhancements we will be doing, include: 1. **Rendering emojis directly from a supported emoji font** - You’ll no longer need `SVGs` for emoji rendering. Instead, HTML character codes will render emojis directly, making it simpler to add new emojis to the emoji panel. 2. **Native input field emoji support** - Perhaps the most **exciting enhancement** is the ability to render emojis directly within input fields, whether added via JavaScript or pasted by users. Previously, the Chat sample used a `:emojicode:` pattern in input fields, which didn’t visually render the emojis: With emoji fonts, this limitation is resolved. Users will see a real-time preview of emojis in the input field, improving the chat’s user experience: 3. **Simplified server-side processing** - The server no longer needs to match `:emojicode:` patterns and replace them with `SVGs`. Messages will now display emojis rendered directly by the font. #### Importing an emoji font To enable usage of certain emojis, you need first to import a `COLRV0` font file. For this guide, we’ll use the [OpenMojiCOLRv0.ttf ](https://github.com/Emoji-COLRv0/Emoji-COLRv0/blob/main/fonts/OpenMojiCOLRv0.ttf)font built using the [https://openmoji.org/](https://openmoji.org) graphics: --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#usage] ## Emoji support: Usage (2/7) 1. Download the font on your machine. 2. Use the `@font-face` CSS rule to import the font. 3. Link the font file using the `src` property and assign it a `font-family`. For example, we’ll name our custom font `OpenMoji`. 4. Apply the font to relevant HTML elements (`html`, `body`, `button`, and `input`) to ensure consistency. **Note that `button` and `input` elements use the system font by default, so explicitly applying the custom font is necessary.** ```css @font-face { font-family: OpenMoji; src: url(./assets/OpenMojiCOLRv0.ttf); } html, body, button, input { font-family: 'Droid Sans', OpenMoji; } ``` \*\*Note: You need to set the default font-family for Gameface to ‘Droid Sans’, as the OpenMoji font lacks numeric symbols. This ensures numbers properly fall back to the default font. \*\* Now you’re ready to add emojis to the UI. #### Updating the emoji panel button To migrate the `SVG` icon for the emoji panel button, replace it with a direct emoji character in the HTML and remove the associated CSS background image styles. ```html
``` Additionally, use the `coh-font-fit` property to adjust the emoji’s size to automatically fit within the button element. Previously, the `background-image` style used the `contain` property for this purpose. --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#usage] ## Emoji support: Usage (3/7) You can read more about the `coh-font-fit` custom `CSS` property [here ](https://docs.coherent-labs.com/cpp-gameface/content_development/fonts_frontend/#font-fit-auto-sizing). ```css .open-emojis-panel-btn { background-image: url(/assets/emojis-open-panel.svg); background-color: transparent; background-size: contain; coh-font-fit: fit; border: none; width: 3.5vh; height: 3.5vh; margin-right: 0.5vh; cursor: pointer; border-radius: 50%; } ``` #### Making the emojis panel to work with the font In the Chat sample, we initially implemented a panel where users could select emojis to include in their messages. Previously, emojis were displayed using `SVG` icons. Now, we’ll enhance this feature by switching to emoji fonts. To render the emojis in the panel, we initially defined an array containing the paths to the `SVG` icons for each emoji. Then, using `data-bind-for` and `data-bind-style-background-image-url` attributes, we displayed all available emojis in the panel. Now, we will adjust the array and update the panel in the `HTML` to use emoji fonts. --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#usage] ## Emoji support: Usage (4/7) ```js const emojis = [ '/assets/emojis/1F600.svg', '\u{1F600}', '/assets/emojis/1F601.svg', '\u{1F601}', '/assets/emojis/1F602.svg', '\u{1F602}', '/assets/emojis/1F603.svg', '\u{1F603}', '/assets/emojis/1F604.svg', '\u{1F604}', '/assets/emojis/1F605.svg', '\u{1F605}', '/assets/emojis/1F923.svg', '\u{1F923}', '/assets/emojis/1F642.svg', '\u{1F642}', '/assets/emojis/1F643.svg', '\u{1F643}', '/assets/emojis/1FAE0.svg', '\u{1F644}', '/assets/emojis/1F609.svg', '\u{1F609}', '/assets/emojis/1F60A.svg', '\u{1F60A}', '/assets/emojis/1F607.svg', '\u{1F607}', '/assets/emojis/1F970.svg', '\u{1F970}', '/assets/emojis/1F60D.svg', '\u{1F60D}', '/assets/emojis/1F929.svg', '\u{1F929}', '/assets/emojis/1F618.svg', '\u{1F618}', '/assets/emojis/1F617.svg', '\u{1F617}', '/assets/emojis/263A.svg', '\u{263A}', '/assets/emojis/1F61A.svg', '\u{1F61A}', '/assets/emojis/1F619.svg', '\u{1F619}', '/assets/emojis/1F972.svg', '\u{1F973}', '/assets/emojis/1F60B.svg', '\u{1F60B}', ]; ``` **Click here to see the new JS file without the differences** --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#usage] ## Emoji support: Usage (5/7) ```js const emojis = [ '\u{1F600}', '\u{1F601}', '\u{1F602}', '\u{1F603}', '\u{1F604}', '\u{1F605}', '\u{1F923}', '\u{1F642}', '\u{1F643}', '\u{1F644}', '\u{1F609}', '\u{1F60A}', '\u{1F607}', '\u{1F970}', '\u{1F60D}', '\u{1F929}', '\u{1F618}', '\u{1F617}', '\u{263A}', '\u{1F61A}', '\u{1F619}', '\u{1F973}', '\u{1F60B}', ]; ``` In the `HTML`, we’ll also update the rendering logic to use the new emoji font approach. ```html
``` This change enables direct rendering of emoji Unicode characters using the `data-bind-html` attribute. Additionally, the `iter` variable now passes the emoji character code directly and this eliminates the need to pass the `index` when clicking an emoji. #### Adding emoji to the message input When a user selects an emoji from the panel, it will be inserted at the current caret position in the input field. Since we are now using fonts, we no longer need to insert the pattern `:emojicode:`. Instead, we can directly add the emoji character code, which will be rendered automatically. Here’s the revised `addEmoji` method: --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#usage] ## Emoji support: Usage (6/7) ```js function addEmoji(emojiIndex) { function addEmoji(emojiCodeString) { const emojiCodeString = `:${emojiIndex}:`; const newInputSelection = input.selectionStart + emojiCodeString.length; const inputValue = input.value; input.value = inputValue.substring(0, input.selectionStart) + emojiCodeString + inputValue.substring(input.selectionEnd, inputValue.length); input.setSelectionRange(newInputSelection, newInputSelection); input.focus(); emojisPanel.hide(); } ``` #### Refactoring the server The Chat sample uses a server to handle message delivery via WebSockets. Previously, the server replaced `:emojicode:` patterns with corresponding `SVG` elements before broadcasting messages. With the new font-based approach, this step is no longer necessary. Here’s the updated server logic: ```js const emojis = require('./src/emojisMapServer'); ... socket.on('chat message', (msg) => { const newMessage = msg.replace(/:[0-9]*:/g, (match) => { const emojiCode = match.replace(/:/g, ''); return ``; }); const d = new Date(); const timeStamp = [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/') + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':'); io.emit('chat message', { msg: `
${newMessage}
${timeStamp}
`, id: socket.id }); io.emit('chat message', { msg: `
${msg}
${timeStamp}
`, id: socket.id }); }); ``` --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#usage] ## Emoji support: Usage (7/7) By eliminating the need for `SVG` replacements, we simplify the server logic and improve performance. --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#conclusion] ## Emoji support: Conclusion These updates enhance the Chat sample by leveraging emoji fonts for rendering emojis in both the panel and the message input. The server logic is also simplified, as it no longer needs to process emoji patterns. The emoji font support in Gameface is a great feature that can be used in many ways to enhance the visual fidelity of the UI components, including displaying text. --- [SOURCE: https://coherent-labs.com/blog/news/emoji-support/#where-you-can-find-the-enhanced-sample] ## Emoji support: Where you can find the enhanced sample? The updated Chat sample is available in the `Samples/uiresources/UITutorials/ChatEmojisWithFonts` folder of the Gameface package. The original sample using `SVG` emojis can be found in the `Samples/uiresources/UITutorials/ChatEmojis` folder. ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/] ## Gameface UI version 1.0.0 released ## Gameface UI version 1.0.0 released news 7/10/2025 Martin Bozhilov 1. Checkbox 1. Documentation 2. Radio and radio button 1. Documentation 3. Dropdown and Dropdown Options 1. Documentation 4. Stepper and Stepper Items 1. Documentation 5. Segment and Segment Button 1. Documentation 6. Slider 1. Documentation 7. ToggleButton 1. Documentation 8. TextSlider 1. Documentation 9. XYSlider 1. Documentation 10. What’s Next We’re excited to announce that [**GameFace UI** ](https://gameface-ui.coherent-labs.com/)is growing!\ In this update, we’ve added new components to make your prototyping experience even faster and more flexible. Below, you’ll find details about the newly introduced components. --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#checkbox] ## Gameface UI version 1.0.0 released: Checkbox The `Checkbox` component provides a customizable checkbox input. It supports three states — `checked`, `unchecked`, and `disabled`. In addition to basic usage, the `Checkbox` component offers flexible slots for deeper customization: - `Label` slot to customize or reposition the checkbox’s label. - `Control` slot to style or replace the checkbox control itself. - `Indicator` slot to modify the checked state indicator. Programmatic control is also available via a `ref`, allowing developers to retrieve values or set the state of the checkbox through code when needed. #### Documentation 📚 For more information and detailed examples, please refer to the [Checkbox documentation](https://gameface-ui.coherent-labs.com/components/basic/checkbox/) --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#radio-and-radio-button] ## Gameface UI version 1.0.0 released: Radio and radio button The `Radio` component acts as a wrapper that allows you to render a set of mutually-exclusive options `Radio.Buttons`. The Radio allows you to programmatically control or retrieve the value of the selected option via `ref` or the `onChange` prop. Just like the `Checkbox`, the `Radio.Button` component offers flexible slots for deeper customization: - `Label` slot to customize or reposition the checkbox’s label. - `Control` slot to style or replace the checkbox control itself. - `Indicator` slot to modify the checked state indicator. #### Documentation 📚 For more information and detailed examples, please refer to the [Radio ](https://gameface-ui.coherent-labs.com/components/basic/radio/)and [Radio.Button ](https://gameface-ui.coherent-labs.com/components/basic/radio-button/)documentations. --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#dropdown-and-dropdown-options] ## Gameface UI version 1.0.0 released: Dropdown and Dropdown Options The `Dropdown` component lets you display a list of selectable options, making it ideal for menus, filters, or game settings. Key features include: - **Scrollable options list:** If there are too many options, the list becomes scrollable. - **Programmatic control:** Use a `ref` or the `onChange` prop to get or set the selected value. The `Dropdown` component also supports several slots for customization: - `Trigger`: Customize the dropdown’s trigger button. - `Placeholder`: Show a placeholder when no option is selected. - `Icon`: Add or customize the icon inside the trigger. - `Track`: Customize the scroll track of the dropdown. - `Handle`: Customize the scroll handle. These features make the `Dropdown` component flexible and easy to adapt to your UI needs. #### Documentation 📚 For more information and usage examples, please refer to the [Dropdown documentation ](https://gameface-ui.coherent-labs.com/components/basic/dropdown/)and [Dropdown.Options documentation ](https://gameface-ui.coherent-labs.com/components/basic/dropdown-options/). --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#stepper-and-stepper-items] ## Gameface UI version 1.0.0 released: Stepper and Stepper Items The `Stepper` component lets users move through a sequence of options, one at a time. You can control the `Stepper` programmatically using a `ref` or the `onChange` prop to get or set the current value. For customization, the `Stepper` provides a `Control` slot. This slot allows you to style or reposition the arrow buttons—place them before or after the stepper options as needed. To define the selectable options, use the `Stepper.Items` component inside `Stepper`, with each option represented by a `Stepper.Item`. #### Documentation 📚 For more details and examples, see the [Stepper documentation ](https://gameface-ui.coherent-labs.com/components/basic/stepper/)and [Stepper.Items documentation ](https://gameface-ui.coherent-labs.com/components/basic/stepper-items/). --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#segment-and-segment-button] ## Gameface UI version 1.0.0 released: Segment and Segment Button The `Segment` component displays a group of mutually exclusive options, similar to the `Radio` component. Users can select only one option at a time. You can control the selected value programmatically using a `ref` or the `onChange` prop. For customization, the `Segment` component provides an `Indicator` slot. This slot lets you style the indicator element, which animates when the selected option changes. To define the selectable options, use the `Segment.Button` component for each option. #### Documentation 📚 For more information and detailed examples, see the [Segment documentation ](https://gameface-ui.coherent-labs.com/components/basic/segment/)and [Segment.Button documentation ](https://gameface-ui.coherent-labs.com/components/basic/segment-button/). --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#slider] ## Gameface UI version 1.0.0 released: Slider The `Slider` component lets users select a numeric value from a defined range by dragging a handle along a track. Key features: - **Customizable range:** Set `min` and `max` values to define the slider’s limits. - **Step control:** Specify the increment between values using the `step` prop. - **Grid display:** Optionally show tick marks along the track. - **Programmatic control:** Access or update the value via a `ref` or the `onChange` prop. The `Slider` component offers several slots for advanced customization: - `Track`: Customize the appearance of the slider track. - `Fill`: Style the filled portion of the track. - `Handle`: Change the look of the draggable handle. - `Thumb`: Display the current value above the handle. - `Grid`: Show tick marks or value indicators along the track. These features make the `Slider` component highly adaptable for different UI needs. #### Documentation 📚 For more details and examples, see the [Slider documentation](https://gameface-ui.coherent-labs.com/components/basic/slider/) --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#togglebutton] ## Gameface UI version 1.0.0 released: ToggleButton The `ToggleButton` component is a flexible UI control that lets users switch between two states, such as “on” and “off.” Key features and customization slots include: - `LabelLeft`: Customize the label displayed on the left side of the toggle. - `LabelRight`: Customize the label displayed on the right side of the toggle. - `Control`: Change the appearance of the toggle button in its unchecked state. - `Indicator`: Style the indicator that appears when the toggle is active. - `Handle`: Customize the handle that users drag to toggle the state. You can also control the `ToggleButton` programmatically using a `ref`, allowing you to get or set its state in your code. #### Documentation 📚 For more information and detailed examples, see the\ [ToggleButton documentation](https://gameface-ui.coherent-labs.com/components/basic/toggle-button/) --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#textslider] ## Gameface UI version 1.0.0 released: TextSlider The `TextSlider` component allows users to select a string value from a list of predefined options by dragging a handle along a track. Key features: - **Programmatic control:** Easily get or set the selected value using a `ref` or the `onChange` prop. The `TextSlider` component supports several slots for customization: - `Track`: Change the appearance of the slider track. - `Fill`: Style the filled portion of the track. - `Handle`: Customize the draggable handle. - `Thumb`: Show the current value above the handle. - `Pol`: Adjust the look of the poles that mark each selectable value. #### Documentation 📚 For more details and examples, see the [TextSlider documentation](https://gameface-ui.coherent-labs.com/components/basic/text-slider/) --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-basic-components-announcement/#xyslider] ## Gameface UI version 1.0.0 released: XYSlider The `XYSlider` component lets users select a value within a two-dimensional space, making it ideal for scenarios where both horizontal and vertical input are needed. Key features: - **Customizable range:** Define the slider’s limits using `minX`, `maxX`, `minY`, and `maxY` props. - **Custom background:** Easily change the background to fit your UI. - **Programmatic control:** Use a `ref` or the `onChange` prop to get or set the current value. The `XYSlider` component provides slots for advanced customization: - `Background`: Change the appearance of the slider’s background. - `Handle`: Customize the look and feel of the draggable handle. These features make the `XYSlider` component flexible and easy to adapt to your UI needs. #### Documentation 📚 For more details and examples, see the [XYSlider documentation](https://gameface-ui.coherent-labs.com/components/basic/xy-slider/) #### What’s Next We’re continuously expanding the Gameface UI component library! Stay tuned for upcoming releases featuring even more components. ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-beta/] ## Gameface UI Beta Released ## Gameface UI Beta Released news 3/11/2025 Mihail Todorov 1. What is GamefaceUI? 1. Why SolidJS? 2. Why is this a beta release? 3. How to use GamefaceUI? 1. Using the boilerplate 2. Using the components only We are thrilled to announce the beta release of GamefaceUI, our state-of-the-art prototyping tool. --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-beta/#what-is-gamefaceui] ## Gameface UI Beta Released: What is GamefaceUI? [GamefaceUI ](https://github.com/CoherentLabs/Gameface-UI/)is a comprehensive collection of components designed to simplify the prototyping of game user interfaces. Built on the [SolidJS ](https://www.solidjs.com/)framework, it provides users with a fast and efficient way to kickstart their projects. #### Why SolidJS? SolidJS is a modern JavaScript framework for building user interfaces. We chose it for our prototyping tool for several reasons: 1. **Performance**: SolidJS is engineered for high performance. It employs fine-grained reactivity, updating only the necessary parts of the DOM, resulting in faster rendering and lower memory usage compared to frameworks like React. 2. **Reactivity Model**: SolidJS’s reactivity model is straightforward and intuitive. It uses reactive primitives that are easy to understand and work with. 3. **Simplicity**: SolidJS offers a simpler API and fewer concepts to learn compared to other frameworks, making it easier for new or less experienced users to get started and be productive quickly. 4. **No Virtual DOM**: Unlike React, SolidJS does not use a virtual DOM. Instead, it compiles templates to real DOM operations, leading to better performance and more predictable behavior. --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-beta/#why-is-this-a-beta-release] ## Gameface UI Beta Released: Why is this a beta release? In this beta release, we are introducing the core components essential for building your UI layouts. We plan to expand the component library and continuously improve based on user feedback. Your insights will be crucial in refining and enhancing GamefaceUI’s design and functionality. --- [SOURCE: https://coherent-labs.com/blog/news/gamefaceui-beta/#how-to-use-gamefaceui] ## Gameface UI Beta Released: How to use GamefaceUI? To use the components, you have two options: you can either download the complete boilerplate template that uses SolidJS with TypeScript and Vite, or integrate them into an existing SolidJS project. #### Using the boilerplate To get started with the boilerplate, navigate to the directory where you want to set up your UI and run the following command: ```bash npx degit CoherentLabs/Gameface-UI ``` This command will download the entire boilerplate into your current directory. If you prefer to create a new directory for the boilerplate, use: ```bash npx degit CoherentLabs/Gameface-UI NEW_FOLDER ``` Where `NEW_FOLDER` is the name of your new folder. #### Using the components only If you already have a SolidJS project set up, you can directly integrate the components. Simply create a new folder for the components and run the following command inside it: ```bash npx degit CoherentLabs/Gameface-UI/src/components ``` ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/html-is-the-best-alternative-to-scaleform/] ## HTML is the best alternative to Scaleform ## HTML is the best alternative to Scaleform news 11/26/2018 Alexandra Ivanov 1. Same workflow, faster development On Wednesday, Autodesk announced their decision to no longer offer Scaleform for purchase. This marks the end of an era in UI game development, shaking up the community and leaving developers with no other option. However, a great Scaleform alternative already exists on the market and it has been steadily taking over UI development for some time. Coherent Labs’ products - Coherent GT and Hummingbird, support the same workflow and features, making them the best Scaleform alternative on the market. Both products offer a smooth transition from Scaleform and allow the user to preserve and continue their work without the need for any additional changes. The standard HTML5 allows easily to manipulate and experiment, instantly seeing the effect. We have created high-performance binding, scripting, and rendering on all platforms, compatible with modern multi-threaded, data-oriented engine architectures. --- [SOURCE: https://coherent-labs.com/blog/news/html-is-the-best-alternative-to-scaleform/#same-workflow-faster-development] ## HTML is the best alternative to Scaleform: Same workflow, faster development Our data-binding systems allows you to efficiently synchronize the state of the UI with the game. The programmers can expose the game data for the designers so they can directly use it in the UI. Even complex use cases such as populating a list of inventory items become easily achievable. All products offered by Coherent Labs empower teams by eliminating dependencies between team members and improving iteration time by letting them work independently of one another. Front-end designers can test their work even without the game running. They can simulate real interactions with the game by mocking all of the game data. Furthermore, changes to the UI can be applied even while the game is running and the UI has already been loaded. Programmers need a few hours to setup the data binding for the UI designers. Many studios foresaw thе end of Scaleform and Flash-based technologies, already converting to Coherent GT and Hummingbird. Our team is ready to assist everyone who is interested in making the same transition by providing the necessary support. ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/on-the-road-to-html5/] ## On the road to HTML5 (1/4) ## On the road to HTML5 news 7/28/2017 Alexandra Ivanov After Autodesk’s announcement that they are stopping the support of Scaleform and will no longer provide the product for purchase, Adobe surprised the community with its announcement: Flash will be phased out in the next 2 years. The recent events left many developers concerned about the future of their professional careers as interactive and UI professionals. Companies were also directly affected by the two announcements and are now searching for alternatives to Flash and Scaleform that can provide them with the same features, tools, and workflow, simultaneously preserving the investment that have previously been made. The founding goal of Coherent Labs was to build the best technology and tools for game UI and interactive applications. After carefully analyzing the competition in the face of Scaleform, based on Flash, a decision was made to base the company’s technology on HTML5. Through the years, this decision became more and more justified as the popularity of Flash was steadily declining while that of HTML5 was evolving. Most of the features previously present only in Flash are now supported in HTML5 and the list keeps growing. A lot has already been written in the posts by Mozilla, Apple and Google. Recently, the number of people using Flash technology has significantly declined, which can be seen from Google’s graph below: Flash usage over a three-year period, taken from Google’s article --- [SOURCE: https://coherent-labs.com/blog/news/on-the-road-to-html5/] ## On the road to HTML5 (2/4) The Adobe Flash plugin itself has been already removed or made optional in the major browsers for years. According to Kongregate, one of the most prominent portals for online games, Flash already is replaced by HTML5. The split of monthly uploads to Kongregate.com among HTML (.html), Flash (.swf), and Unity WebPlayer (.unity3d), taken from [Kongregate’s article ](http://blog.kongregate.com/html5-is-here/). The best thing about Flash was how enabling the technology was for creators and the variety of powerful developer tools it provided. That workflow is not going away – Adobe CC (former Adobe Flash) and Animate are actively been developed by Adobe and in fact, already have been exporting to HTML5 for some time. Companies and professionals will be able to keep their skills and tools as well as workflow, but take advantage of the future improvements empowered by the HTML5 platform and standard. --- [SOURCE: https://coherent-labs.com/blog/news/on-the-road-to-html5/] ## On the road to HTML5 (3/4) As our products are based on HTML5 technology, our team makes sure that developers are getting the optimal performance and using all the advantages of the underlying platform. That is why we have developed a plugin for enhanced HTML5 export. By default, Animate uses canvas and JS to emulate features. We map features to clean and standard HTML5 to provide many benefits to developers – better performance, cleaner, smaller code, and ability to directly connect the game objects to the UI. Some of our customers have already migrated 100% of their existing Scaleform UIs to Coherent GT and Hummingbird. Additionally, to the many new HTML5 features, such as styling and modern JavaScript, they got deeper integration with all popular game engines and multi-platform support, even for platforms where Flash was not available, like consoles or IOS. As with any change, there are some challenges in migrating from Scaleform and Flash to HTML5. First, many projects have used Actionscript to achieve things like tween and animations along with advanced UI controls functionality. Unfortunately, those libraries cannot be directly used. In most cases there is already an existing HTML5 functionality, obsoleting the need for such libraries like WebAnimation, which is an existing HTML5 API. Using such APIs has the additional benefits of smaller and simpler code that directly provides the platform features. An additional benefit is better performance and enables users to GPU accelerate the graphics. Other libraries like Box2D have their JavaScript alternatives that can be directly used. --- [SOURCE: https://coherent-labs.com/blog/news/on-the-road-to-html5/] ## On the road to HTML5 (4/4) Another popular use of Flash was to play videos, and specifically DRM-protected content. That is no longer the case as current browsers now support EME and can directly play the protected content. If developers positively want to keep using Flash, there are a few open source implementations that can partially play Flash content. For instance, you can look at Haxe or OpenFL. If you have an existing Flash or Scaleform project and would like to learn how to convert it to a modern technology and keep the workflow as well as investment, please contact us to learn how . Our team can assist you in migrating both small and extensive projects from Scaleform/Flash. ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/say-hi-our-new-coherent-brand/] ## Say hi, new coherent brand! (1/3) ## Say hi, new coherent brand! news 6/6/2019 Alexandra Ivanov In order to understand why we decided to rebrand, we want to give you a bit of a background perspective on who we are and how we ended up here. Coherent Labs was created in 2012 by four programmers who decided that they can come up with a better solution for UI creation than what was already on the market. Since the beginning, the company has grown to over 40 people and has released multiple generations of products that are used by some of the most renowned game development studios in the world. Since the main focus during the first few years was creating products that solve hard technological problems rather than developing a marketing strategy, our brand was not very coherent (pun intended). That, coupled with the otherwise great additions to our product line, led to some confusion among our customers on what each product offered. Another reason behind our rebranding is the meaning behind the name Coherent Labs: - logical = our workflow and the way we create our software - consistent = our business relationships with our clients and partners - forming a unified whole = our holistic approach: we offer technical expertise, support, and development on demand - the scientific and meticulous approach with which we tackle challenges on a daily basis = we’re basically scientists but instead of mixing potions, we use HTML5 to make the magic happen 🙂 --- [SOURCE: https://coherent-labs.com/blog/news/say-hi-our-new-coherent-brand/] ## Say hi, new coherent brand! (2/3) Along with our new appearance, for which we have industry experts Battalion to thank (you might know some of their clients - SoundCloud, for example) we now have a streamlined product line which is based on our client-centric approach. We have always listened to what our customers and partners had to say and taken everything, good or bad, to heart. In the past, we’ve marketed our products based on how we made them. Different companies make games differently, with each studio having a preferred approach. We want to make everyone’s jobs easier and we want our software to alleviate some of the major pressure points in making UI (a developer - artist collaboration, for example). This is reflected in our 2 new products - Coherent Gameface and Coherent Prysm, which differ in the type of workflow a company prefers, and not in the underlying technology. Coherent Gameface is the latest CL tech meant for people with web development experience who like to use modern HTML5, JavaScript and CSS and like to do their coding by hand while also utilizing modern libraries like React.jsCoherent Prysm is made to be used with a visual workflow in mind and requires writing minimal to no amount of code. With it, you can use the power of Adobe Animate and create more complex compositions. And the output is still HTML/CSS/JS, and not Flash. --- [SOURCE: https://coherent-labs.com/blog/news/say-hi-our-new-coherent-brand/] ## Say hi, new coherent brand! (3/3) Since the beginning, we at Coherent Labs, have not stopped pushing ourselves to go further and take our technology to new heights. The company didn’t merely change throughout the years. We evolved and it was time for our brand to follow suit. Keep an eye out for our hashtags #gameuisolved #madewithCLtech on social media for company updates and sneak peeks on the lives of Coherent employees. ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/unit-2-games-and-coherent-labs/] ## Unit 2 Games - realizing their vision for UGC games with the help of CL tech (1/3) ## Unit 2 Games - realizing their vision for UGC games with the help of CL tech news 8/1/2019 Alexandra Ivanov One of our main goals at Coherent Labs has always been to make game developers’ lives easier by streamlining and simplifying UI creation. When we saw the same ambitions to create an intuitive and easy to use tool, that would enable more people to create the games they want in Unit 2 Games’s new project Crayta, we were thrilled. So we chatted with Andrew Shenton, Technical Director at Unit 2 Games about Crayta and the way they used our tech to realize their vision. - What was the inspiration behind the idea for Crayta? We had a vision that everyone would be able to create, share, and discover UGC games easily; to build a game which was profoundly driven by player UGC as its primary feature allowing players to create new types of game genres, experiences, and personalized content. - What can players expect from Crayta? By combining innovative industry technologies to empower our players we offer them a new experience with unparalleled levels of freedom and ease of access. Players will have the ability to express themselves through building games together in a new and engaging way and will have the opportunity to discover and explore novel and compelling game types. - Why did you choose Coherent Tech for your UI? --- [SOURCE: https://coherent-labs.com/blog/news/unit-2-games-and-coherent-labs/] ## Unit 2 Games - realizing their vision for UGC games with the help of CL tech (2/3) In our previous titles, UI had always been costly and unwieldy. We began experimenting with WebKit and were impressed by how using a browser basis streamlined the workflow for both our in-house and player-created UI. Unfortunately, the performance coming from these experiments was insufficient for our needs. We surveyed the landscape for a similar solution and tried out Coherent GT2 which significantly improved the performance and provided enhancements to our workflows. With GT2 as our foundation, we managed to support UGC UI at manageable performance limits in our production builds without needing to spend significant manpower on wholesale optimization. We’ve since migrated to Coherent Labs’s next-generation product, GameFace, which has even further improved UI performance in Crayta. - What do you see as the greatest strengths/benefits of our tech? The main advantage is putting control in the hands of our content creators. The web-like nature of the tools has also allowed us to recruit from a more standardized skill-set than was previously possible. In combination with rapid performance and cross-platform support, the tools have accelerated our ability to deliver on Crayta’s vision for a UGC-powered future for games. - What would you say is the overall contribution that our tech made to your project? Helping us extend our vision for fundamental User Generated Content to player UIs through the accessibility of the HTML/CSS /JS stack. It also provides pipelines and experience to ensure that we can always accomplish our goals in a comparatively short time-scale --- [SOURCE: https://coherent-labs.com/blog/news/unit-2-games-and-coherent-labs/] ## Unit 2 Games - realizing their vision for UGC games with the help of CL tech (3/3) - Where do you see Crayta in the next 3-5 years? We hope that as Crayta matures our community will create and discover popular new game types, genres, and sub-genres, similar to how modders created Defense of the Ancients (DotA) from Warcraft 3, and Auto Chess in Dota2. We would like Crayta to be an environment where these new games, their player community, and content creators can grow and thrive together. Just about everyone at Coherent Labs is an avid gamer and we have all played player-made content, so you can imagine how excited we are for Crayta’s release and for being a part of it. 2020 can’t come soon enough! ## On this page --- [SOURCE: https://coherent-labs.com/blog/news/what-you-need-to-know-about-hummingbirds-support-for-nintendo-switch/] ## What you need to know about Hummingbird's support for Nintendo Switch (1/2) ## What you need to know about Hummingbird's support for Nintendo Switch news 4/24/2018 Alexandra Ivanov ##### As of 24th of April 2018 Coherent Labs is the only UI solution on the market that has the privilege of supporting Nintendo Switch™. We have been wanting to say that for a while now! The communication between the two teams - Nintendo & Coherent Labs - started back in December of last year and has been going without a hitch to this day, when we can officially offer our SDK for Nintendo to clients. ##### Fully multiplatform UI solution From a business perspective, adding Nintendo Switch to our portfolio means our clients can now enjoy the workflow and performance benefits of the leading UI tool on the last platform they couldn’t. That makes the lives of our sales team much, much easier as there is virtually nothing left we can’t offer to our clients at this point. Being the most popular UI solution used for games with the widest variety of platform support we were eager to add Nintendo Switch to the list, as it was the last major platform missing from our portfolio. If you are wondering how this whole ordeal started, it’s quite simple – we got a request from a prospective client whose game was to be developed for Nintendo Switch. The next step was to get in touch with the Nintendo team and see what needed to be done to make this platform support become a reality. --- [SOURCE: https://coherent-labs.com/blog/news/what-you-need-to-know-about-hummingbirds-support-for-nintendo-switch/] ## What you need to know about Hummingbird's support for Nintendo Switch (2/2) Eager to know which is the game that made us go through this whole ordeal? Stay tuned and you will find out. For now, however, let us tell you a bit about the technical challenges we encountered while integrating Hummingbird. ## On this page --- [SOURCE: https://coherent-labs.com/blog/releases/gameface-1-0-released/] ## Gameface 1.0 released! ## Gameface 1.0 released! releases 12/7/2018 Dimitar Trendafilov 1. Custom elements 2. Virtual lists 3. Support for UWP ARM 4. Migrating from Hummingbird 5. Tell us your thoughts! ##### The last step to complete our rebrand is to release the new versions of Coherent Gameface and Coherent Prysm and it’s nigh time we delivered those. Let me tell you all about them. Coherent Gameface, as you’ve probably seen elsewhere is the game UI solution for developers with love for the web stack. HTML5 is a great technology and by using it you benefit from the massive community, talent pool and existing libraries for HTML and JavaScript. Not to mention that frontend developers can work separated from the core gameplay engineers. To learn more about Coherent Gameface, visit its page or check its features. Starting with the more exciting news - compared to Hummingbird 1.14, Coherent Gameface 1.0 comes with a bunch of new things. --- [SOURCE: https://coherent-labs.com/blog/releases/gameface-1-0-released/#custom-elements] ## Gameface 1.0 released!: Custom elements Custom elements are a relatively new addition to the HTML standard which allows for the creation of…well, custom elements! Custom elements allow you create customizable and reusable component-like classes that can then be composed to create the final UI. Read more about them on [MDN ](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements). Syntax as easy as 1-2-3: ```html <-- Define the custom element --> <-- Use it as you would any other element --> ``` --- [SOURCE: https://coherent-labs.com/blog/releases/gameface-1-0-released/#virtual-lists] ## Gameface 1.0 released!: Virtual lists Virtual lists are a brand new feature to Coherent Gameface which solves one specific problem we’ve seen people encounter time and again with our data binding system. Whenever you bind some list of items, it’s often that you need to display only a part of it. That ‘part of it’ usually falls into one of these categories: - Pagination - display some fixed number of items and potentially allow the user to go to the following items (e.g. display 5 weapons at a time in an inventory). - Filtering - display all items that match some predicate (e.g. show all unlocked weapons). - Sorting - display all items in some order. This release will simplify the pagination part but we’ll also add the 2 others in one of next year’s releases. So for example: ```html
``` This allows you control how many and which elements are visible in a simple manner. See [the docs ](https://coherent-labs.com/Documentation/cpp-gameface/d1/ddb/data_binding.html#Virtual_list)for further info about usage information. --- [SOURCE: https://coherent-labs.com/blog/releases/gameface-1-0-released/#support-for-uwp-arm] ## Gameface 1.0 released!: Support for UWP ARM UWP has been part of our supported platforms for the better part of this year but we were missing ARM as an architecture and this release closes the last gap. You can now run Coherent Gameface on mobile devices with Windows as well as PC and Xbox One. --- [SOURCE: https://coherent-labs.com/blog/releases/gameface-1-0-released/#migrating-from-hummingbird] ## Gameface 1.0 released!: Migrating from Hummingbird For everyone upgrading from Hummingbird to Coherent Prysm, the steps needed to update are rather simple and available in a document your favorite support team will share separately. Do contact them at to get access to it. --- [SOURCE: https://coherent-labs.com/blog/releases/gameface-1-0-released/#tell-us-your-thoughts] ## Gameface 1.0 released!: Tell us your thoughts! For a full list of changes, as always you can check the [changelog ](https://coherent-labs.com/changelog-gameface/)and hit us on [twitter ](https://twitter.com/coherentlabs)or anywhere else to tell us what you think. I am also very curious about your thoughts on our new style. We’ve put a lot of effort in the rebrand and we are pretty happy with how it went but it end it’s your opinion that matters the most. Enjoy your New Year’s Eve and stay tuned for Prysm 1.1 coming out in January! Credits for the above [video ](https://www.youtube.com/watch?v=RN8ss708b6M)go to [CyberWebFX](https://www.youtube.com/c/CyberWebFX) ## On this page --- [SOURCE: https://coherent-labs.com/blog/releases/prysm-1-0-released/] ## Prysm 1.0 released! ## Prysm 1.0 released! releases 12/7/2018 Dimitar Trendafilov 1. Improving quality of life 2. Support for UWP ARM 3. Migrating from Hummingbird 4. Tell us your thoughts! ##### The last step to complete our rebrand is to release the new versions of Coherent Gameface and Coherent Prysm and it’s nigh time we delivered those. Let me tell you all about them. Coherent Prysm, as you’ve probably seen elsewhere is the game UI solution for artists. Adobe Creative Cloud is an amazing set of content creation tools. Through a custom plugin for Adobe Animate (aka the Coherent Exporter), we bridge the gap between game UI and Adobe CC making it easy for artists to work directly without programmer involvement. To learn more about Coherent Prysm, visit its page or check its features. Starting with the more exciting news - compared to Hummingbird 1.14 and Coherent Exporter 0.95, Coherent Prysm 1.0 comes with a bunch of new things. ##### Support for overflow Coherent Prysm’s Animate plugin now supports control over the ‘overflow’ of elements. Overflow determines what happens with any part of the element that would usually be outside the element’s boundaries - in different cases you might want it clipped, visible or you might want the element to become a scrollable container. You can also control overflow in each direction (e.g. you might want to have the element scrollable vertically and clipped to the side). --- [SOURCE: https://coherent-labs.com/blog/releases/prysm-1-0-released/#improving-quality-of-life] ## Prysm 1.0 released!: Improving quality of life This release also adds a couple of minor fixes and improvements to the Coherent Prysm Animate plugin which are meant to save you time. Most notably, exporting to HTML will no longer pollute your history thus you’ll be able use undo/redo as you need to and as you would expect to. Figuring out how you use Animate and Coherent Prysm together is one major goal of ours and we will be dedicating more time in upcoming releases to improving how the two collaborate to give you better workflow. With this in mind, do give us a shout out at for anything you find problematic. --- [SOURCE: https://coherent-labs.com/blog/releases/prysm-1-0-released/#support-for-uwp-arm] ## Prysm 1.0 released!: Support for UWP ARM UWP has been part of our supported platforms for the better part of this year but we were missing ARM as an architecture and this release closes the last gap. You can now run Coherent Prysm on mobile devices with Windows as well as PC and Xbox One. --- [SOURCE: https://coherent-labs.com/blog/releases/prysm-1-0-released/#migrating-from-hummingbird] ## Prysm 1.0 released!: Migrating from Hummingbird For everyone upgrading from Hummingbird to Coherent Prysm, the steps needed to update are rather simple and available in a document your favorite support team will share separately. Do contact them at to get access to it. --- [SOURCE: https://coherent-labs.com/blog/releases/prysm-1-0-released/#tell-us-your-thoughts] ## Prysm 1.0 released!: Tell us your thoughts! For a full list of changes, as always you can check the changelog and hit us on twitter or anywhere else to tell us what you think. I am also very curious about your thoughts on our new style. We’ve put a lot of effort in the rebrand and we are pretty happy with how it went but it end it’s your opinion that matters the most. Enjoy your New Year’s Eve and stay tuned for Prysm 1.1 coming out in January! Credits for the above [video ](https://www.youtube.com/watch?v=RN8ss708b6M)go to [CyberWebFX](https://www.youtube.com/c/CyberWebFX) ## On this page --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (1/8) ## Incoming Renoir backend API changes software-development 2/6/2019 Dimitar Trendafilov In this blog post we will describe the incoming changes to Renoir’s backend API and the motivation for them. The current backend API was designed around DirectX 11 and therefore implementing a DirectX 11 backend with the current API is simple and intuitive. The mapping between backend and DirectX 11 API methods is very straightforward. Also Renoir’s backend API proved to be suitable for implementing backends for other graphics APIs like DirectX9 and OpenGL. As the industry evolved, API vendors began shifting to lower-level graphics APIs, which provided more fine grained control over the GPU. As a result of that shift AMD announced their new graphics API Mantle and Microsoft followed with DirectX 12. The goals of both graphics APIs were similar - reducing CPU overhead and allowing direct access to all GPU features. The development of AMD’s Mantle API was eventually suspended due to the rise of popularity and the similar aims of DirectX 12 and OpenGL’s successor Vulkan. Once DirectX 12 was officially released, we naturally started implementing a Renoir backend for it and while we encountered some minor problems with the original backend API design, we managed to solve them and deliver a DirectX 12 backend to our products. --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (2/8) Apple decided to create their own low-level, low-overhead graphics API called Metal. A couple of years later they announced the deprecation of OpenGL and OpenGLES respectively for Mac and iOS. We decided that it would be best to get ready for the next decision of Apple to fully deprecate something and implement a Metal backend. Metal is designed around the principles of the modern low-level compute and graphics APIs like Vulkan and DirectX 12. It is specifically tailored to bring better performance than OpenGL to both Mac and iOS applications. A key concept in both Metal and Vulkan is the render pass. The definition provided by Apple for a render pass is a collection of commands that updates a set of render targets. Metal also introduces a render command encoder object, which is simply defined as The object to use for encoding commands for a render pass. In Metal we need to create a new render command encoder object for each logical render pass. The render pass concept is introduced in order to achieve high performance on GPUs with tiled architecture and to keep the code and hardware tied together without much abstraction in-between. The information that you must specify in order to create a render command encoder in Metal includes the color, depth and stencil attachments that you are going to draw in, if they should be cleared on load and whether MSAA texture resolve should happen at the end of the render pass when storing the render targets. --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (3/8) When we started designing and implementing the Metal backend, we encountered several problems, which showed us that Renoir’s backend API is not fully suited to handle a graphics API designed around the render pass concept. The information needed for creating a render command encoder was scattered in backend API. Some methods provided only part of the information and some required the creation of a new encoder although there may already exist one. Additionally in Metal you can’t have more than one active render command encoder. These specifics of the graphics and backend API were the cause of multiple problems while implementing the Metal backend. The major ones were: --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (4/8) - The backend API uses two separate commands for binding and clearing render targets (SetRenderTarget and ClearRenderTarget). However, as mentioned above when creating a render command encoder we should specify if some attachment should be cleared on load. This is very efficient on tiled GPUs as starting a render pass is tied together with the clearing of a texture. Additionally there is no other method in the Metal API, which can directly be used to clear a render target. - The ClearRenderTarget command is often issued to just clear the depth and stencil attachments in the middle of a render pass, which means that we will often do the expensive operation of resetting the current render command encoder and therefore beginning a new render pass with different load actions for the depth and stencil attachments. - When MSAA textures are enabled, Renoir frequently needs to resolve them and issues to the backend the command ResolveRenderTarget with the proper MSAA and resolve texture. Resolve can be issued in the middle of a render pass, which again means that we will need to create a new render command encoder just to resolve the textures and then reset the old one. This happens due to the Metal API only allowing render target resolve implicitly at the end of a render pass and to do so, an appropriate store action should be set on render pass creation. --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (5/8) We managed to workaround most problems in the Metal backend by basically saving the render pass state, ending the current render pass and creating a new one for the currently issued operation. In the case of the ResolveRenderTarget problem we even had to reset the old render pass after the end of the method. These workarounds incur a CPU and GPU performance cost, which we minimized in order to provide a fully functional **Metal Backend in Gameface 1.1 and Prysm 1.1**. However, in order to be able to take full advantage of the Metal graphics API and avoid the workarounds, we decided to make some changes to the backend API and rework the Metal backend in Gameface 1.2 and Prysm 1.2. These changes include: --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (6/8) - Two new backend API commands - BeginRenderPass and EndRenderPass. They are issued only when a new backend capability is enabled in the FillCaps method. This capability tells Renoir to issue these new commands instead of the SetRenderTarget and ResolveRenderTarget commands. The parameters in the BeginRenderPass command provide all the information needed to create a render command encoder - the render targets, if they should be cleared on load and if resolve should happen at the end of the render pass. This change allows for efficient clearing of the render targets and also solves the problem with the resolve in the middle of a render pass. - Another new capability, which when enabled tells Renoir to replace the ClearRenderTarget command with a DrawIndexed command, which does a fullscreen clear quad through the use of a **new ClearQuad vertex and pixel shader**. This change solves the problem of needing to reset the render command encoder in order to clear the render targets. We also decided to further simplify the implementation of all the modern low-level graphics APIs by doing the following changes: --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (7/8) One of the problems observed during the implementation of the DirectX12 backend was overwriting constant buffers. This was happening, because for a given frame we were binding a constant buffer and sending the commands to the GPU and then for the next frame we were again writing to this constant buffer while it was still being used by the GPU. The problem was also present in other backends like Metal. We solved it easily by adding a ring buffer containing multiple constant buffers. However, this problem was forcing Renoir’s clients to write the ring buffer code in multiple backends, so in order to simplify the backend’s implementation we decided to move the circular buffering scheme to the Renoir rendering library and exposed the size of the ring buffer as a configurable capability in the backend. When this size is set to the maximum count of buffered frames in your pipeline, updating the constant buffers’ data consists of simply finding each constant buffer object and placing the new data in it. The SDK takes care not to overwrite any buffers currently used by the GPU. We decided to move the information whether a render target is MSAA to the CreatePipelineState command, because it is part of DirectX 12, Metal and Vulkan pipeline state objects. The EnableColorWrites flag is removed from the SetRenderTarget command and the ColorMask field of the Pipeline object is used instead in the CreatePipelineState backend method. --- [SOURCE: https://coherent-labs.com/blog/software-development/incoming-renoir-backend-api-changes/] ## Incoming Renoir backend API changes (8/8) These changes are synchronized with all the provided current sample backends, but will require modifications in the custom ones. You can further understand the details of the required changes from the transition guide, which will be added soon to the documentation of Gameface and Prysm. We are confident these changes of Renoir’s backend API will allow you to achieve simpler and at the same time more performant backend implementations, so expect them in **Gameface 1.2 and Prysm 1.2**. ## On this page --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (1/8) ## Introducing Vulkan support in the Coherent Technology software-development 7/26/2019 Dimitar Trendafilov In this blog post, we will share the challenges we faced during the implementation of the Vulkan backend for our rendering library Renoir and how we overcame them. In order to better understand the exciting challenges we faced, we will start by laying out the main requirements for Vulkan support. --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (2/8) - It must implement the Renoir backend API, which is used for all backends and their corresponding graphics APIs. Keep in mind that our backend API is designed according to the properties of our software products, namely a game UI SDKs. This results in Renoir not knowing what resources (e.g. textures) will be used in the next frame as the user of our SDK has the ability to load and change them dynamically (e.g. through JavaScript). This problem is elaborated further later in the blog post. - It must use our shader cross-compilation pipeline and therefore our base common HLSL shaders. We avoid significantly changing these shaders for a specific graphics API as this defeats the purpose of having one set of shaders for all APIs. - It must run on all the Vulkan supported platforms and adhere to the hardware-specific limits of all the possible [Desktop and Mobile ](https://docs.coherent-labs.com/cpp-gameface/what_is_gfp/requirements/)devices our products support. - It should be easy to understand and high performance at the same time. This is caused by the fact that the Vulkan backend implementation we provide is just a sample one and our clients must have the ability to modify it to suit their specific engine. In most cases, they don’t even need to modify the sample as the one we provide matches their requirements. - It also should provide an option for custom memory allocations while having a default implementation. The Vulkan API also introduces some requirements and limitations, which influenced our backend design decisions. --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (3/8) - Vulkan gives full control of the memory management to the developer. ‣ You have to manually query the memory requirements and determine the memory type for each allocation. This is not always easy as it heavily depends on the user’s graphics card. ‣ You should not use separate allocation for each resource as you cannot have more than 4096 simultaneous memory allocations even for modern graphics cards. This means that you have to implement a custom allocator, which splits a couple of huge allocations into smaller chunks. This is why we decided to create our own allocator interface and wrap the [Vulkan Memory Allocator ](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator)by default, but also enable clients to implement and provide custom allocators. - Buffers and Images (Textures) in Vulkan are provided to the shaders through descriptors and these descriptors are organized and aggregated in descriptor sets. You can’t bind individual descriptors, but only one or multiple descriptor sets. ‣ Sets are allocated from descriptor pools by providing them a corresponding descriptor set layout. ‣ The descriptor set layout describes how the data is laid out in the shader by specifying each descriptor binding. ‣ You can’t bind more than 4 descriptor sets for a significant amount of GPUs. --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (4/8) - The descriptor sets are updated through the vkUpdateDescriptorSets API method, which isn’t recorded in the command buffer with the other Vulkan commands but executes immediately. This can lead to an invalid command buffer if the descriptor set, which is updated is either in use by a command buffer executing on the GPU or in the recording state. - It is preferred to group your descriptors by binding frequencies. E.g. if you have multiple uniform buffers and textures in a descriptor set and only one of them changes, then you will have to pay the cost for rebinding all of them. The design of descriptor sets is very convenient and high performance when you have information upfront of what resources will be used for a given scene or at least for a large number of frames. However, as mentioned in our requirements, we don’t have that information and therefore we have to update and bind descriptor sets multiple times per frame, which incurs a performance cost.In the Vulkan backend, we separate our descriptors into four types of sets - vertex and pixel shader uniform buffers, samplers and textures. Each type of descriptor set has a corresponding descriptor set manager. This manager allocates a chunk of descriptor sets each frame for every type and allows descriptor set reuse for sets updated with the same data. --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (5/8) We also have a circular buffer of descriptor pools with default size 4 (can be modified based on the number of buffered frames in a user’s pipeline). Every frame we reset the current descriptor pool and pass it to the managers, so they can allocate their descriptor set chunks. The descriptor pool has a maximum amount of descriptor sets it can allocate for each frame and this value can also be modified for heavier scenes. Additionally, we use dynamic uniform buffers in order to keep our UB updates to a minimum by just updating whole uniform buffer once and providing different dynamic offsets in it on the binding. This whole scheme is acceptable for us, as we don’t change the samplers and uniform buffers that often. We can optimize our texture descriptor set management by using array of textures and a push constant to index in the array. This strategy requires adding a preprocessing step in the Vulkan backend, which based on the Renoir commands collects all the information for the resources that are going to be used for a given frame and updates the texture array. However, this will both require changing our common HLSL shaders to include the array of textures and the push constant only for the Vulkan backend and will complicate our sample backend implementation, which as mentioned in our requirements is not desirable. --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (6/8) Most of the other problems we hit, we have already solved similar ones during the implementation of backends for other graphics APIs (DirectX12, Metal, etc.). However, there were still a couple of Vulkan specific tricks we had to use and problems we stumbled on: --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (7/8) - We were forced to use the VK_KHR_MAINTENANCE1 device extension because we need to specify negative viewport height in order to y-flip the clip-space to framebuffer coordinate transform. This is needed for Vulkan clip coordinates as they have different orientation compared to the D3D clip coordinates (motivation for this behavior). - Due to the nature of Vulkan image layouts, the backend expects every user texture or render target, which is passed to it by the user’s application or engine to be in the VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL layout. After the backend enqueues all of its commands in the user-provided command buffer, then the user textures and render targets are again transitioned to the VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL layout. - It is usually hard to determine the right time to destroy a framebuffer. The reason for this is that you have to destroy it when all of its attachments are no longer used by the GPU and destroyed. Otherwise, validation layers errors are hit. Most other rendering frameworks (e.g. bgfx, The Forge) destroy them at the end of a frame. - We had a bug in one specific blur effect test, which happened only on Nvidia graphics cards and was caused by using texture, which is not initially cleared immediately after creation. We set it for a render pass color attachment with a clear load operation and regular store operation. Then we used it to achieve a blur effect and when we ended the render pass, random artifacts were present in the texture’s blur. The synchronization of the image was correct. Additionally, RenderDoc was no help, because it always showed correct rendering with no artifacts. All of this was not present on AMD graphics cards and everything worked fine. - There were many Nvidia and AMD quirks as the one described in the previous point. We are kind of used to that, but there were a larger amount of such quirks we hit for the Vulkan backend than any other. For example, at one point of our implementation, we didn’t synchronize the writing to our vertex, index, and uniform buffers. There was no barrier for a buffer in the whole backend. The Vulkan validation layers weren’t warning about that. As a matter of fact, the rendering was working 99% of the time. On AMD and Nvidia graphics cards the failing tests were different and again the artifact was not present in the RenderDoc replay, because it serializes the commands and it usually is unable to catch synchronization artifacts. Due to the rendering almost always working, we considered that the problem was something small like one missing image barrier or one wrong render pass action, not general buffer synchronization, so it took some time to fix that issue. - We tried to find very extensive validation layers to try to get ideas for some of the problems we hit. We were unable to find such layers, but there is already some work on that. --- [SOURCE: https://coherent-labs.com/blog/software-development/vulkan-support/] ## Introducing Vulkan support in the Coherent Technology (8/8) The Vulkan backend is included for the native Windows SDK in Gameface and Prysm 1.3 and will be included in the native Android SDK in Gameface and Prysm 1.4. Vulkan support for our UE4 plugin is also added in the 1.4 release version. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/] ## 3D Map with UI markers - Adding interactions (part 2) ## 3D Map with UI markers - Adding interactions (part 2) ui tutorials 2/13/2025 Martin Bozhilov 1. Overview 2. Showing tooltip on hover 1. Create collision box for every POI actor 2. Adding hover events 3. Changing UI scale based on zoom level 1. Adjusting the size of area markers with custom events 2. Implementing the custom events in the UI 3. Adjusting collision boxes with zoom level --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#overview] ## 3D Map with UI markers - Adding interactions (part 2): Overview This is the second and final part of the [“3D Map with UI markers”](https://coherent-labs.com/blog/?search=3d+map+with+ui+markers\&exactMatch=true) series. In the previous part, we laid out the project structure and implemented markers display. We are going to implement a tooltip that appears when a point of interest is hovered over by the mouse. The tooltip will display the name of the POI and its description. Additionally, we will enhance the visuals of our UI by adjusting the size of the UI elements depending on the zoom level by the player. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#showing-tooltip-on-hover] ## 3D Map with UI markers - Adding interactions (part 2): Showing tooltip on hover (1/7) The approach we took for implementing this feature was to use `Collision boxes` that will detect when the cursor is over them. #### Create collision box for every POI actor We are going to create a `Set POI Collision` method which will spawn collision boxes when the level initializes to avoid doing it manually for every POI we have. In this method, we are going to: - Loop through all POI actors and add box collisions to them - Calculate the relative scale of the boxes based on their distance from the player camera - Enable the input and set overlap events to `true` for each collision box - Add each collision box to the `POI Collision Box` array variable for later use - After the loop is finished, enable mouse over events from the controller class The helper method `Set Collision Box Scale` will be used to calculate the scale of the collision box relative to the object’s distance to the camera. We will need the Z position of each POI as an input and achieve our desired result by the following formula: - Camera Z location + current spring arm length = `Camera location`. - `Distance to Actor` = `Camera Location` - Actor Z location. - After we have the distance to the actor, we will scale it down by multiplying it by 0.001. Additionally, you can fine-tune this by clamping the final result or lowering the `distance to actor` value - in our case, we have done both. One tip here is to use the `Set Hidden in Game` node in the `Set POI Collision` method to visualize the bounds of the collision box, like so: #### Adding hover events --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#showing-tooltip-on-hover] ## 3D Map with UI markers - Adding interactions (part 2): Showing tooltip on hover (2/7) After setting up the collision boxes, we need to make them listen for mouse input. We will achieve this by binding our POI actors to the `On Begin Cursor Over` and `On End Cursor Over` events. Before doing that, we need to go back to the content browser and create a `POI_Blueprint` actor class and replace all instances of our points of interest with it. This allows us to add an `index` class variable to help provide the correct information to the tooltip. Then in the blueprint editor of `POI_Blueprint` create an `index` integer variable. We can now proceed with the main part of this section - binding the events. We are going to bind the events on `Event Begin Play`. The bound events will be responsible for toggling the visibility of the tooltip, while the up-to-date info will be handled on every tick - only if the tooltip is visible to optimize performance. Before adding the blueprint nodes for the logic, we have to create the struct for the tooltip, a variable to represent the structure, and another variable to hold the hovered actor so its information can be extracted and passed to the tooltip. Create a structure called `tooltipState` with the following fields: And also create the variables: With that out of the way, we now have to define 2 methods - one for toggling the visibility of the tooltip and another to update its state (name, description, location). Let’s begin by creating and implementing `Update Tooltip Visibility` first: Now, let’s set up the logic on `Event Begin Play` in the `GameState` BP: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#showing-tooltip-on-hover] ## 3D Map with UI markers - Adding interactions (part 2): Showing tooltip on hover (3/7) 1. We will create the tooltip `data-bind` model. 2. Then loop through all the actors and call their blueprint class where we will set the correct index for each element. 3. For every actor, we will call `On Begin Cursor Over` and in the event body, we will store the active actor POI and call `Update Tooltip Visibility` with the visibility boolean set to `true`. 4. `On End Cursor Over` we will only call `Update Tooltip Visibility` with the visibility boolean set to `false`. With that out of the way, we now need to implement the `Update Tooltip State` method. The logic for this method will be the same, with the only difference being that we will update the other fields except for `visibility`. In order to pass the correct information only when needed, on `Event Tick` we are going to check if the tooltip is visible and if it is, we will get the correct POI’s information by providing the `POIs` array with the index of the Active POI. Then, we will pass the correct information to the `Update Tooltip State` method we just defined. The only thing left to make this all work is to connect it to the Frontend. Let’s add the tooltip element and connect it to Unreal with `data-binding` ```html
``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#showing-tooltip-on-hover] ## 3D Map with UI markers - Adding interactions (part 2): Showing tooltip on hover (4/7) What is left is to add some styling and the utility class `visible` and our tooltip is ready! ```css .poi-tooltip { position: absolute; transform: translate(-50%, 50%); color: white; text-transform: capitalize; text-align: center; z-index: 99; opacity: 0; flex-direction: column; justify-content: center; align-items: center; background-image: url(./pois/tooltipBG.png); background-position: center; background-size: 100% 100%; padding: 1.5vmax 0 0.5vmax; width: 25vmax; transition: opacity 0.1 linear; } .poi-tooltip-name { font-size: 1.5vmax; padding-bottom: 0.5vmax; margin-bottom: 0.5vmax; border-bottom: 2px solid #FFD700; } .poi-tooltip-description { font-size: 0.75vmax; } .visible { opacity: .75; } ``` ### Changing UI scale based on zoom level {#changing-ui-scale-based-on-zoom-level} To enhance the immersion of our UI, we will make it scale based on the current zoom level. - On maximum zoom, the area markers will fade out, and the POI markers will scale a bit. - On medium zoom, the area markers will show, and the POI markers will scale down. - On minimum zoom, the area markers will scale up. #### Adjusting the size of area markers with custom events We are going to put the logic for this functionality in our `TopDownCamera` pawn actor, where the camera that shows the UI is located and where the zoom logic is handled. We must first get a reference to our GameState to manipulate its variables. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#showing-tooltip-on-hover] ## 3D Map with UI markers - Adding interactions (part 2): Showing tooltip on hover (5/7) Then let’s create a method called `Adjust UI Scale` and connect it to the `Event Tick` event after our zoom method Now let’s implement the `Adjust UI Scale` method. The logic for it will be relatively simple. In our zoom logic, we have set the `SpringArm`’s max zoom-out value to be 20000. So in this method, we will check how much the camera is zoomed and send appropriate events to the UI. - If the zoom level is below 5000, we will set the `Zoomed` field in our `MapModel` structure to `true`, which will tell the UI to scale the POIs, and we’ll also send the `zoomedInMax` event to the UI. - If the zoom level is between 5000 and 10000, we will set the `Zoomed` field to `false`, scaling down the POI marks, and we’ll send the `zoomedIn` custom event to the UI. - If the zoom level is above 10000, we will only send a `zoomedOut` event to the UI. **Note:** Before we initialize any logic, we must first check if the binding are ready, otherwise when trying to update the model, we’ll get an error. Now let’s head back to our UI and implement the custom events. #### Implementing the custom events in the UI Create a javascript file - `index.js` and link it to your HTML ```html ``` Then in the `index.js` we will get all of our markers and we will listen for our custom events with the `engine.on()` method. The whole logic will be controlled by toggling different classes based on the event sent. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#showing-tooltip-on-hover] ## 3D Map with UI markers - Adding interactions (part 2): Showing tooltip on hover (6/7) ```js const areaMarkers = document.querySelectorAll('.area-marker') engine.on('zoomedOut', () => { areaMarkers.forEach((areaMarker) => { areaMarker.classList.remove('mark-hidden') areaMarker.classList.add('mark-small') }) }) engine.on('zoomedIn', () => { areaMarkers.forEach((areaMarker) => { areaMarker.classList.remove('mark-hidden') areaMarker.classList.remove('mark-small') }) }) engine.on('zoomedInMax', () => { areaMarkers.forEach((areaMarker) => { areaMarker.classList.add('mark-hidden') }) }) ``` Now let’s also add the appropriate utility CSS classes to make it all happen. - `mark-small` will shrink the area marks text. - `mark-hidden` will set the opacity of the area mark to 0 - essentially fading out the text. ```css .mark-small { font-size: 1.5vmax; } .mark-hidden { opacity: 0; } ``` Let’s also add a utility class for our points of interest that we will toggle based on the `zoomed` field in the model. ```css .poi-small { width: 2.25vmax; height: 2.25vmax; } ``` And another one for the content of the POIs which we will use to straighten the POI when the player zooms in on it. ```css .poi-content { // Existing styles transition: transform 0.1s linear; } .poi-content-zoomed { transform: rotateX(0) rotateZ(-45deg); } ``` Finally connect it to the elements with the `data-bind-class-toggle` attribute --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui-part-2/#showing-tooltip-on-hover] ## 3D Map with UI markers - Adding interactions (part 2): Showing tooltip on hover (7/7) ```html
``` And with that our frontend is complete! Now if you save everything and play your level your UI should react to the zoom level of your camera! #### Adjusting collision boxes with zoom level One final thing we can implement is to dynamically change the size of the collision boxes on our POIs that control the tooltip. Adding this will be very simple since we are going to reuse our `Set Collision Box Scale` method that we used when creating the boxes. In your player pawn blueprint on `Event Tick` after the `Adjust UI Scale` method, connect a new method called `Adjust Collision Box Scale` where we will implement this logic. Let’s proceed by setting up the `Adjust Collision Box Scale` method. We will loop through all the collision boxes, call the `Set Collision Box Scale` method, and set the new scale with the `Set Relative Scale 3D` method. And with that, we conclude our UI! Feel free to expand on it and create a stunning 3D map for your game! ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/] ## 3D Map with UI markers - Project setup & displaying markers (part 1) ## 3D Map with UI markers - Project setup & displaying markers (part 1) ui tutorials 2/13/2025 Martin Bozhilov 1. Overview 2. Resources 3. Project Initialization - Unreal Engine 1. Setting Up Player Movement 2. Placing Actors for POIs and Area Markers 4. Data-Bind Model setup 1. Creating the Structures 2. Setting Up the Points of Interest 3. Creating the Data-Bind Model 4. Displaying Points of Interest and Area Markers 5. Project Setup - Frontend 1. Import cohtml.js 2. Creating the UI elements 6. Result 7. What is next? --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#overview] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Overview In this tutorial series, we’ll use Unreal Engine v5.4 and blueprints to design a 3D map level. The map will consist of UI elements (such as points of interest and area markers) that are dynamically moved on the HUD based on the location of in-game objects. Additionally, the points of interest will be hoverable and will display a tooltip with information about the location. This tutorial will be split into two parts. In this part, we will focus on displaying the map markers on the map. In the second part, we will implement interaction features such as showing a tooltip when a POI element is hovered over by the mouse. For the UI, we will use Gameface’s [native ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/)and [UE ](https://docs.coherent-labs.com/unreal-gameface/integration/ui-scripting/databinding/)data-binding features to bind game data to the UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#resources] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Resources - Font: [GodOfWar](https://www.dafont.com/godofwar.font) - [Top-down camera movement tutorial](https://www.youtube.com/watch?v=hIuZf0BniJA) - [Top-down camera zoom tutorial](https://www.youtube.com/watch?v=ncuZl3IloPw) --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#project-initialization---unreal-engine] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Project Initialization - Unreal Engine (1/2) We’ll begin by setting up the project in Unreal Engine. Use the [getting started guide ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/)from our documentation to install the Gameface plugin and integrate it into an existing project or use the sample project created by the installer. After that’s done, you can create your 3D level. In this tutorial, we are going for a pirate game theme, and our map will be a deserted island. #### Setting Up Player Movement The first step is to set up the movement of the player. For our project, we followed: - [Strategy Game Controller ](https://www.youtube.com/watch?v=hIuZf0BniJA\&t)tutorial to set up the pawn actor and the camera movement logic - [WASD Camera Movement ](https://www.youtube.com/watch?v=ncuZl3IloPw)tutorial for the zoom logic. After following the tutorials, create a `Game State` Blueprint and add it to the `Game Mode` of our level. The major part of our logic will be handled and managed by the `Game State` Blueprint. In our case, we named it `3DMapGameState`. #### Placing Actors for POIs and Area Markers The next major task is to extract the data from the game objects to use it in the UI. We took the approach of placing `Actors` in our world, on top of our points of interest (enemies, treasure chests, etc.), which actors we will get the `world position` of to accurately place our UI elements. After creating and placing the actors, we must label them for easy access. We are going to place 2 entries in the `Tags` array: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#project-initialization---unreal-engine] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Project Initialization - Unreal Engine (2/2) - Element with index 0 will be the name of the POI (dock, enemy, treasure) which we will show in our UI when the POI is hovered. - Element 1 will be used to get all actors and manipulate them with the `Get All Actors of Class with Tag` Blueprint node. When that is done, we are going to do the same for our area markers. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#data-bind-model-setup] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Data-Bind Model setup (1/4) Before we begin setting up any blueprint logic, we must set up our `model` which we will use in the UI - as it plays a very central role in our project. To achieve this, we must do the following: 1. Create `structures` for the points of interest, the area names, and the model itself. 2. In the `GameState` blueprint, create variables that will hold the state and update the model dynamically. 3. On `Event Tick`, update the model with the correct position of our elements relative to the screen. 4. Send these changes to the UI with `data-binding`. #### Creating the Structures For this map UI, we are going to have 2 main UI elements - **points of interest** (POI) and **area markers**. Let’s create `structs` for both. In the content browser, create a `POIStruct` that will hold all the information we need for the POIs. Create a struct with fields: - coordinates - type: `Vector 2D` - to hold the x and y coordinates of the actor. - name - type: `name` - to hold the name of the POI. - description - type: `string` - to hold the description of the POI that will be shown in the tooltip. Let’s do the same for the area markers. The fields will be the same, except we don’t need `description` as the elements will be just text. The last `struct` we need is for the `model` we are going to use in the UI. Create a `structure` named `MapModel` that will hold: - An array of `POIStruct` elements. - An array of `AreaMarkers` elements. - zoomed - `boolean` flag we will use to toggle styles in the UI relative to the zoom level of the map. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#data-bind-model-setup] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Data-Bind Model setup (2/4) Each element in these arrays will be bound to the actors in our world. #### Setting Up the Points of Interest After the actors have been placed in the world, we can now work with their data. Head to the Event graph in the `GameState` BP and create a new method called `Init Variables`. There we will initialize and connect the actors with the structs we have just created, as well as initialize some other variables. To fill the `structs` with information for the POIs, create a variable called `Marker Descriptions` with `Map` type where we will define the description of the POIs. Lastly, create all the other variables we are going to need for our logic. **Expand to view variable description** - Gameface HUD - Will be used to hold reference to the `GameFace HUD` object. - Actor POI - Here we will store the actors for the points of interest. - Map Model - This is our model, which will interact with our UI. - POIs - An array of `POIStruct` elements, which will hold the info about the POIs data. - POI - Instance of the `POIStruct` type, which we will use to map POI data and add it to the POIs array. - Area Names Actor - Same purpose as the Actor POI variable but for the area markers. - Area Names - Same purpose as the POI variable but for the area markers. - Area Names Array - Same purpose as the POIs variable but for the area markers. - Player Camera - Will be used to hold reference to the camera object. With that out of the way, let’s finally set up the blueprint logic for this method. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#data-bind-model-setup] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Data-Bind Model setup (3/4) 1. First, set the reference for the `GameFace HUD` and the Camera objects. 2. Then, get all actors with tag `POI` and set them in the `Actor POI` array. 3. Loop through the array and for each entry, get the tag with index 0 - which is the POI’s type (enemy, treasure, etc.) and find the corresponding element from the `Marker Descriptions` array to find the appropriate description for the POI. 4. Next, set the members (`name` and `description`) in `POIStruct`. 5. Lastly, add the newly created POI to the POIs array. 6. Repeat the process for the area markers, with the exception that they don’t have a description field, so this part is skipped. #### Creating the Data-Bind Model Once the `Init Variables` function is ready, we can proceed with configuring the game model for the UI. In the Game State Blueprint, on `Event BeginPlay`: 1. Call `Init Variables` to initialize all required variables. 2. Set the `MapModel` structure with the now populated `POIs` and `Area Names Array` variables. Additionally, add a boolean variable named `Are Bindings Ready`. This will be used as a conditional check to ensure the UI models can be updated from the game. Without this check, attempts to update the models before the bindings are ready will fail. Next, use `Create Data Model From Struct` followed by `Synchronize Models` to create the `mapModel` model from the `MapModel` structure. #### Displaying Points of Interest and Area Markers --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#data-bind-model-setup] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Data-Bind Model setup (4/4) After initializing our model and all necessary variables, we need to update the `x` and `y` coordinates of each element in the model on `Event Tick` to display the UI elements at the correct place in our HUD. To achieve this, we will create a method in the `GameState` Blueprint called `Map World Location to Screen`. This method will project the actors’ locations into 2D screen coordinates, which we will use to display the POI and area markers at the correct locations relative to the player’s view. Next, we will create another method - `Update POI State` that will: 1. Accept the new coordinates and the element’s index. 2. Update the element in the POIs array at that index. 3. Update the model and call `Update Whole Data Model from Struct` and `Synchronize Models` to reflect the changes in the UI. What’s left is to connect everything in the Event Graph. We will check if the bindings are ready with the `Are Bindings Ready` boolean we defined earlier. When that returns true, we will map through all the POI actors and call both methods we just defined. After we finish looping through the `Actor POI` array, we will do the exact same for the area names. Note that we have to create a new method `Update Area Names State`, which will have the exact same logic as the `Update POI State` method. However, since it is a different structure, we can’t reuse the one we used for the POIs. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#project-setup---frontend] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Project Setup - Frontend (1/4) Let’s quickly set up the frontend so we can display our map elements. We’ll begin by creating an `index.html` file in the `uiresources` folder. #### Import cohtml.js To enable communication between the UI and the game, the `cohtml.js` library must first be imported. #### Creating the UI elements Next up, let’s create our UI elements and bind them to the model with `data-binding`. ```html
``` Here, we are using `data-bind-for` to loop through all elements in the `Pois` array in the model. We are controlling the position on the screen of each map element with the `data-bind-style-left` and `data-bind-style-top` attributes, which change the `left` and `top` CSS properties of the element every time the model updates (which in our case is every tick). --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#project-setup---frontend] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Project Setup - Frontend (2/4) Finally, we are creating the path to the background image with `data-bind-style-background-image-url` by dynamically creating a string from the name of the POI. In this case, the images are located relative to the `index.html` file in a `pois` folder. The logic for the area markers is the same, but we are updating the value of the HTML element with `data-bind-value` instead of updating a background image. The only thing left is to add some styles to our elements. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#project-setup---frontend] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Project Setup - Frontend (3/4) ```css @font-face { font-family: GodOfWar; src: url(./GODOFWAR.TTF); } body { width: 100vw; height: 100vh; overflow: hidden; margin: 0; perspective: 2000px; font-family: GodOfWar; } .poi-container { transform-style: preserve-3d; } .poi { position: absolute; width: 3vmax; height: 3vmax; /* Translation is applied so the element is positioned from its center as opposed to the top left corner which is by default */ transform: translate(-50%, -50%); z-index: 1; } .poi-content { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border: 0.2vmax solid rgb(168, 143, 0); background-color: #333333; transform: rotateX(25deg) rotateZ(-45deg); box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.5); } .poi-image { width: 100%; height: 100%; transform: rotate(45deg); background-size: 75% 75%; background-position: center center; background-repeat: no-repeat; } .area-marker-container { transform-style: preserve-3d; } .area-marker { position: absolute; font-size: 2.5vmax; letter-spacing: 1rem; color: white; opacity: 1; text-transform: uppercase; z-index: 2; text-shadow: 1px 1px 10px black; transform: rotateX(25deg) translate(-50%, -50%); } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-map-ui/#project-setup---frontend] ## 3D Map with UI markers - Project setup & displaying markers (part 1): Project Setup - Frontend (4/4) To enhance the depth and the 3D effect of the UI, we have added a `perspective` on the `body` element to enable 3D CSS transformations. This allows us to rotate our elements in 3D space, making it feel like the area markers and POIs are laying directly on top of the world, as opposed to being part of the UI. #### Result If you save, compile and play your level In Unreal you should see similar results! #### What is next? In the next tutorial, we’ll enhance our map by adding interactivty. Check it out here 3D Map with UI markers (part 2) ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-subtitles/] ## 3D Subtitles (1/2) ## 3D Subtitles ui tutorials 3/28/2024 Veneta Kochovska This is a sample that shows how to create 3D subtitles in Gameface: The subtitles are `div` elements that use CSS transform with [perspective ](). Using CSS transformations you can rotate the subtitles in the same way that the character that is speaking is facing. 3D effects can emphasize the source of speaking. This sample uses a background image for simplicity, but it illustrates interesting ways of subtitle positioning. The subtitle container is an [absolutely positioned ](https://developer.mozilla.org/en-US/docs/Web/CSS/position)element that has `perspective: 1000px`. Refer to the [documentation ](https://developer.mozilla.org/en-US/docs/Web/CSS/perspective)for more information regarding css perspective. ```html ``` ```css .container { position: absolute; perspective: 1000px; perspective-origin: center; } ``` The subtitle element is a `

` element that has `backdrop-filter: blur(7px);` style. The backdrop filter creates a blur effect on the background without affecting the text itself. The rotation is achieved using CSS `transform: rotateY(310deg);`. The perspective style applied to the parent of the paragraph is what makes the rotated subtitle look 3D: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/3d-subtitles/] ## 3D Subtitles (2/2) ```css .subtitle { backdrop-filter: blur(25px); margin: 0px; padding: 10px 40px; font-size: 30px; color: aliceblue; } ``` The pop-up effect is a CSS animation. It moves the subtitle over the Y axis and scales it from 0 to 1 which makes it look as if it appears from bellow: ```css .popup { animation-duration: 2s; animation-name: popup; animation-iteration-count: infinite; animation-timing-function: linear; } @keyframes popup { from { transform: translateY(50px) scaleX(0); } 50% { transform: translateY(0px) scaleX(1); } 100% { transform: translateY(0px) scaleX(1); } } ``` The last keyframe stays on the same styles just to create a delay effect before the next iteration starts. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/] ## Creating interactive game level selection menu ## Creating interactive game level selection menu ui tutorials 11/1/2024 Martin Bozhilov 1. Overview 2. Resources 3. Getting started - Unreal Engine 1. Setting up the Bink videos 2. Creating the Render Targets 3. Creating the HUD class 4. Setting up the view and the input 5. Implementing the blueprint logic 6. Implementing video draw logic 7. Implementing our custom event 8. Putting it all together 4. Getting started - Frontend 1. Import cohtml.js 2. Setting up the layout 3. Adding the animated card styles and structure 4. Connecting the videos to the HTML 5. Creating the sliced border effect 6. Trigger hover event from the UI 5. Full source code Learn how to create interactive game level selection menu cards. Hovering over any card triggers a video preview of that level, providing players with a dynamic and immersive glimpse of the environment before they dive in. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#overview] ## Creating interactive game level selection menu: Overview In this tutorial, we’ll guide you through implementing a game-level selection menu with interactive videos, allowing them to play as animations when players interact with them. We will use Unreal’s built-in `Bink Video` plugin for seamless video integration with the [Live Views ](https://docs.coherent-labs.com/unreal-gameface/advanced-features/texturesinui/liveviews/)feature of Gameface. This setup ensures smooth playback directly from Unreal Engine, creating a visually engaging experience for your players. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#resources] ## Creating interactive game level selection menu: Resources The videos for this UI were taken from [Freepik ](https://www.freepik.com/). List of videos: - [Skyline Passage](https://www.freepik.com/free-video/animation-train-background-crossing-beautiful-landscape_3358616) - [Verdant Meadows](https://www.freepik.com/free-video/motion-graphic-spring-landscape-with-trees-river_3294755) - [The twilight Groove](https://www.freepik.com/free-video/motion-graphic-hand-drawn-flat-design-enchanted-forest-frame_3294694) - [The Silent Shrine](https://www.freepik.com/free-video/motion-graphic-set-torii-gates-water_3294146) - [Neon Horizon](https://www.freepik.com/free-video/motion-graphic-gradient-japanese-street-with-neon-colours_3294012) --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---unreal-engine] ## Creating interactive game level selection menu: Getting started - Unreal Engine (1/6) We’ll begin by setting up the project in Unreal Engine. Use the [getting started ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/)guide from our documentation to install the Gameface plugin and integrate it into an existing project or use the sample project created by the installer. Once that’s complete, create a new blank map in Unreal Engine to start configuring your setup. #### Setting up the Bink videos First, we need to convert the video files we wish to use into `Bink` format. You can follow [the official guide ](https://dev.epicgames.com/documentation/en-us/unreal-engine/bink-video-for-unreal-engine)in the UE documentation for step-by-step instructions on setting up your videos. **Important:** Make sure to place your videos in the `Content/Movies` directory within your Unreal Engine project folder. Unreal Engine will not recognize them if they’re stored elsewhere. #### Creating the Render Targets Next up, for the live view to work we need to create a `TextureRenderTarget2D` texture for each of our videos and save it in an accessible location within the project files. In our case, we made a separate folder called `Render Targets` placed in the Blueprints folder and placed the Render Targets there. After that we have to set the dimension of each `Render Target` to match the resolution of our videos. In our case that is `1280x720`. To set this, double-click on the Render Target file and locate the dimension settings on the right panel. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---unreal-engine] ## Creating interactive game level selection menu: Getting started - Unreal Engine (2/6) If you are just getting started with Unreal Engine or the `Live views` feature, you can get more aquainted with it by checking out our other [Unreal tutorials ](https://coherent-labs.com/blog/?search=live+views\&exactMatch=true)utilizing the power of `Live Views` or check out [our documentation ](https://docs.coherent-labs.com/unreal-gameface/advanced-features/texturesinui/liveviews/)to read more about them. #### Creating the HUD class To define a custom event with parameters, we need to create a C++ class that extends the `CohtmlGameHUD` class provided by the Gameface plugin. This custom C++ class will then be used as the HUD class type for our Blueprint HUD class. We will follow the [UI Scripting with C++ guide ](https://docs.coherent-labs.com/unreal-gameface/integration/ui-scripting/jsinteractions/#ui-scripting-with-c)to define the custom event and make it accessible in our Blueprints. The event will take a single argument — the index of each video as we loop through them. Start by creating the header file as follows: ```cpp #pragma once #include "CoreMinimal.h" #include "CohtmlGameHUD.h" #include "MyCohtmlGameHUD.generated.h" UCLASS() class AMyCohtmlGameHUD : public ACohtmlGameHUD { GENERATED_BODY() public: virtual void BeginPlay() override; UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = Gameplay) void TogglePlay(const int index); private: UFUNCTION() void BindUI(); }; ``` In this header file, we define the handler that will execute when the JavaScript event TogglePlay is triggered. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---unreal-engine] ## Creating interactive game level selection menu: Getting started - Unreal Engine (3/6) Now, let’s implement this in the C++ source file: ```cpp #include "MyCohtmlGameHUD.h" #include void AMyCohtmlGameHUD::BeginPlay() { Super::BeginPlay(); GetCohtmlHUD()->ReadyForBindings.AddDynamic(this, &AMyCohtmlGameHUD::BindUI); } void AMyCohtmlGameHUD::BindUI() { GetCohtmlHUD()->GetView()->RegisterForEvent("TogglePlay", cohtml::MakeHandler(this, &AMyCohtmlGameHUD::TogglePlay)); } ``` In the `BindUI` method, we register the `TogglePlay` event, which will be triggered from the frontend whenever we want to control video playback. Once you’ve created and compiled this class, you can set up your HUD Blueprint class. Assign this newly created HUD class as the active HUD in your map’s World Settings. This setup enables the `HTML` to display as the UI for your game. #### Setting up the view and the input **If you have already integrated Gameface with Unreal Engine you can skip this section** Create a `Setup Input` method in the previously created BP to enable user input for the UI: To initialize our `HTML` page for the UI, setup the view and set the input to the view in the blueprint you created. #### Implementing the blueprint logic To implement the logic for our animated menu UI, we’ll need to create three variables in our Blueprint: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---unreal-engine] ## Creating interactive game level selection menu: Getting started - Unreal Engine (4/6) - **Bink Media Players Array**: An array of `Bink Media Player` items that will hold the video files. - **Render Targets Array**: An array of `Texture Render Target` items to hold the render textures for each video. - **Active Video Booleans Array**: An array of `boolean` values, which we’ll use to control which video is currently active. Each boolean will indicate whether a video at a specific index is playing. After creating these three array variables with the appropriate types, compile the Blueprint to initialize them. Populate each array with the relevant elements: - **Bink Media Players Array**: Add the `Bink videos` you want to display. We named our variable `BinkVideos` - **Render Targets Array**: Add the `render targets` for each video. We named our variable `Textures` - **Active Video Booleans Array**: Set each `boolean` value to `false` by default, so no video is active at the start. We named our variable `hoveredState` **Important**: Ensure that the indexes of each video in the `Bink Media Players array` correspond to the same indexes in the `Render Targets array`. This way, each video will correctly match its respective `render target`, allowing us to control them accurately within the Blueprint logic. With that out of the way, let’s start implementing the core logic of our UI. #### Implementing video draw logic As explained in our [documentation on Bink integration ](https://docs.coherent-labs.com/unreal-gameface/integration/videosupport/), we need to call the `Draw` method on each `Bink video` instance every tick to display them in the UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---unreal-engine] ## Creating interactive game level selection menu: Getting started - Unreal Engine (5/6) Since we have an `array` of 5 videos we are going to achieve that with the help of a `For Each Loop` node. The loop will iterate through all videos, drawing each one onto the corresponding Render Texture. By matching the index of each video in the `Bink Media Players` array with the index in the `Render Targets` array, we ensure each video displays on its correct texture. The blueprint setup will look like this: #### Implementing our custom event To meet our goal of playing each video only when it’s interacted with, we’ll use the custom event we defined earlier in `C++`. You can add this event in the Blueprint by right-clicking in the editor and searching for the name we assigned it — `Toggle Play` in this case. The logic is straightforward. We’ll use the `Toggle Play` event to toggle the values in our boolean array. In the Event Tick, we’ll check which index in the boolean array is set to true, indicating the active video. Only the video at that index will play, while others will pause. We’ll send the appropriate video index as a parameter to the event from the `frontend`, allowing us to target specific videos. In the Blueprint, the setup looks like this: #### Putting it all together With our custom event in place, we can now enhance our logic by iterating over the Booleans array to determine the active video. For each boolean in the array: - If the value is `true`, we play the corresponding video. - If the value is `false`, we pause the video. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---unreal-engine] ## Creating interactive game level selection menu: Getting started - Unreal Engine (6/6) Additionally, we can call the `seek` method to reset the video when switching states, ensuring each video starts from the beginning upon activation. As the `seek` method expects to be passed a `time`, we can just drag the node and click `promote to variable` and leave it like that as it defaults to 00:00. The complete setup, with all the necessary nodes added, will look like this: With that the Unreal Engine implementation is done and we can proceed with setting up our UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---frontend] ## Creating interactive game level selection menu: Getting started - Frontend (1/6) We’ll begin by creating an `index.html` file in the `uiresources` folder. #### Import cohtml.js To enable communication between the UI and the game, the `cohtml.js` library must first be imported. ```html ``` #### Setting up the layout The layout for this UI will be quite simple. We will add a `background-image` on the body and an element with class of `background-filter` to apply a filter on the body image. Additionally, we will define a wrapper to wrap our content and a `card-wrapper` element to hold our interactive menu card elements. ```html

Select A Location

``` And the styles: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---frontend] ## Creating interactive game level selection menu: Getting started - Frontend (2/6) ```css @font-face { font-family: 'Inknut Antiqua'; src: url('./font/InknutAntiqua-SemiBold.ttf'); font-weight: normal; font-style: normal; } body { margin: 0; width: 100vw; height: 100vh; position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; font-family: "Inknut Antiqua", serif; background-image: url('./assets/background.png'); background-size: cover; background-position: center; background-repeat: no-repeat; } .background-filter { width: 100%; height: 100%; background-color: black; opacity: 0.75; position: absolute; top: 0; left: 0; z-index: 1; } h1 { color: white; text-shadow: 1px 1px 5px black; font-size: 2.5vmax; margin-top: 1vh; margin-bottom: 0; } .wrapper { width: 90%; height: 90%; display: flex; flex-direction: column; align-items:center; position: relative; z-index: 2; } .card-wrapper { display: flex; justify-content: space-between; align-items: center; width: 100%; } ``` #### Adding the animated card styles and structure The html structure of our cards will be the following: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---frontend] ## Creating interactive game level selection menu: Getting started - Frontend (3/6) ```html
Skyline Passage
44%
Verdant Meadows
65%
The Twilight Grove
20%
The Silent Shrines
58%
Neon Horizon
99%
``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---frontend] ## Creating interactive game level selection menu: Getting started - Frontend (4/6) #### Connecting the videos to the HTML Connecting the Bink videos to display in our HTML is pretty straightforward, we simply need to copy the `Render Target` reference from Unreal and add it as the source of our `` elements: ```html ``` #### Creating the sliced border effect To achieve the sliced border effect, we’ll use the `CSS mask-image` property. For this trick to work, we are going to need 2 images: - A border image with a transparent center. - A solid color-filled version of the element. We’ll apply the border image as a mask on a `::before` pseudo-element attached to the main `.animated-card` element. This pseudo-element will be slightly larger than the card contents, creating the appearance of an actual border around the card. ```css .animated-card { width: 18%; height: 70%; position: relative; overflow: visible; cursor: pointer; transition: transform 0.2s ease-in-out; filter: grayscale(100%); // Graying out the inactive cards } .animated-card::before { content: ''; width: 102%; height: 102%; background-color: white; mask-image: url('./assets/video-border.png'); mask-size: 100% 100%; position: absolute; left: -1%; top: -1%; z-index: 3; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---frontend] ## Creating interactive game level selection menu: Getting started - Frontend (5/6) **Note:** The `background-color` on the `::before` pseudo-element determines the visible border color. The actual colors in the mask image are irrelevant, as `mask-image` only considers solid and transparent areas to define what is shown. Currenly, our elements should look like this: To complete the design, we need to add the fill image to the inner section of the video wrapper, which contains the video and its accompanying information. This inner section is the `card-content-wrapper` element. Add the following CSS: ```css .card-content-wrapper { mask-image: url('./assets/video-fill.png'); mask-size: 100% 100%; overflow: hidden; } ``` Applying this mask to the `card-content-wrapper` will hide the top corners of the inner content, allowing the `pseudo-element` (with the border effect) to be visible around the edges. This creates the final polished look we want! *You can find the whole CSS source file in the final section.* #### Trigger hover event from the UI With the design finalized, the last step is to trigger the `Toggle Play` event we defined in our Blueprints, sending it the correct video index. Start by creating an `index.js` file and include it in the HTML’s `` section. In index.js, we’ll loop through all the video elements and attach two event listeners: `mouseover` and `mouseleave`. These will trigger the play/pause functionality when a user hovers over or leaves a menu item. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#getting-started---frontend] ## Creating interactive game level selection menu: Getting started - Frontend (6/6) ```js const videos = document.querySelectorAll('.animated-card') videos.forEach((video, index) => { video.addEventListener('mouseover', (event) => { engine.trigger(`TogglePlay`, index) }) video.addEventListener('mouseleave', (event) => { engine.trigger(`TogglePlay`, index) }) }) ``` **Important**: Ensure that the videos in your HTML are in the same order as in the `Bink videos` array variable defined in your Blueprints. This alignment ensures that each index matches correctly, so the intended video plays or pauses as expected. With this the UI is completed! --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#full-source-code] ## Creating interactive game level selection menu: Full source code (1/5) HTML --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#full-source-code] ## Creating interactive game level selection menu: Full source code (2/5) ```html Document

Select A Location

Skyline Passage
44%
Verdant Meadows
65%
The Twilight Grove
20%
The Silent Shrines
58%
Neon Horizon
99%
``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#full-source-code] ## Creating interactive game level selection menu: Full source code (3/5) CSS --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#full-source-code] ## Creating interactive game level selection menu: Full source code (4/5) ```css @font-face { font-family: 'Inknut Antiqua'; src: url('./font/InknutAntiqua-SemiBold.ttf'); font-weight: normal; font-style: normal; } body { margin: 0; width: 100vw; height: 100vh; position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; font-family: "Inknut Antiqua", serif; background-image: url('./assets/background.png'); background-size: cover; background-position: center; background-repeat: no-repeat; } .background-filter { width: 100%; height: 100%; background-color: black; opacity: 0.75; position: absolute; top: 0; left: 0; z-index: 1; } h1 { color: white; text-shadow: 1px 1px 5px black; font-size: 2.5vmax; margin-top: 1vh; margin-bottom: 0; } .wrapper { width: 90%; height: 90%; display: flex; flex-direction: column; align-items:center; position: relative; z-index: 2; } .card-wrapper { display: flex; justify-content: space-between; align-items: center; width: 100%; } .animated-card { width: 18%; height: 70%; position: relative; overflow: visible; cursor: pointer; transition: transform 0.2s ease-in-out; filter: grayscale(100%); } .animated-card:nth-child(2), .animated-card:nth-child(4) { margin-bottom: 7.5vh; } .animated-card:nth-child(3) { margin-bottom: 15vh; } .animated-card::before { content: ''; width: 102%; height: 102%; background-color: white; mask-image: url('./assets/video-border.png'); mask-size: 100% 100%; position: absolute; left: -1%; top: -1%; z-index: 3; } .animated-card:hover { filter: none; transform: scale(1.02); } .animated-card:hover .video { transform: scale(1.1); } .animated-card .video { width: 100%; height: 100%; transition: transform 0.2s ease-in-out; } .card-content-wrapper { mask-image: url('./assets/video-fill.png'); mask-size: 100% 100%; overflow: hidden; } .card-content { position: absolute; width: 100%; top: 0; left: 0; color: white; } .card-content-heading { padding: 2vh 2vh 1vh; text-align: center; text-shadow: 1px 1px 5px black; font-size: 1vmax; margin-bottom: 0.5vh; } .card-content-progression { text-align: center; font-size: 1.2vmax; text-shadow: 1px 1px 10px black; line-height: 2; } .skyline-passage .card-content-heading { background-color: #312D7A44; } .meadows .card-content-heading { background-color: #54700c6e; } .twilight-groove .card-content-heading { background-color: #24025B6e; } .silent-shrines .card-content-heading { background-color: #3a3c657d; } .neon-horizon .card-content-heading { background-color: #230BA86e; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/animated-menu-items-ui/#full-source-code] ## Creating interactive game level selection menu: Full source code (5/5) JavaScript ```js const videos = document.querySelectorAll('.animated-card') videos.forEach((video, index) => { video.addEventListener('mouseover', (event) => { engine.trigger(`TogglePlay`, index) }) video.addEventListener('mouseleave', (event) => { engine.trigger(`TogglePlay`, index) }) }) ``` Image masks Video Border\ Video Border Fill ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/camera-tilt/] ## Creating a camera tilt gauge ## Creating a camera tilt gauge ui tutorials 2/10/2025 Mihail Todorov 1. Setting up the gauge 2. Controlling the gauge 3. Integrating with Your Game 1. Sending the data from our game 2. Receiving the data in our UI 4. In conclusion A camera tilt gauge is a valuable UI element in many games, helping players stay oriented when navigating uneven terrain, flying vehicles, or controlling a dynamically tilting camera. Whether you’re designing a racing game, a flight simulator, or an action-adventure title, a well-designed tilt gauge can improve player awareness. In this guide, we’ll explore how to create a functional and visually appealing tilt gauge using UI elements and game logic. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/camera-tilt/#setting-up-the-gauge] ## Creating a camera tilt gauge: Setting up the gauge (1/2) First, let’s create the basic HTML structure for our camera tilt gauge. We’ll use a combination of HTML and CSS to design the gauge. ```html
``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/camera-tilt/#setting-up-the-gauge] ## Creating a camera tilt gauge: Setting up the gauge (2/2) ```css .side-scroll { height: 29vh; overflow-y: hidden; width: 3vh; position: absolute; display: flex; flex-direction: column; top: 50%; transform: translateY(-50%); } .scroll-item { display: flex; align-items: center; margin: 1vh 0; height: 1vh; } .scroll-item-active .dash { width: 1.4vh; } .scroll-item-active .dot { animation: dot 0.5s forwards; } .dash { width: 1vh; height: 0.1vh; background-color: white; position: relative; transition: all 0.2s; } .dot { width: 0.7vh; height: 0.7vh; border-radius: 50%; border: 0.35vh solid #faeac3; margin: 0 0.2vh; } @keyframes dot { from { width: 0.7vh; height: 0.7vh; } to { width: 1.2vh; height: 1.2vh; } } ``` To create a balanced design, we’ll add `side-left` and `side-right` classes to the `side-scroll` elements to position them on either side of the screen. ```css .side-left { left: 3%; } .side-right { right: 2%; align-items: flex-end; } ``` Additionally, we’ll reverse the order of the dots and dashes on the right side to create a mirrored effect. ```html
``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/camera-tilt/#controlling-the-gauge] ## Creating a camera tilt gauge: Controlling the gauge (1/2) To control the gauge, we’ll implement some JavaScript functions: one to handle the camera tilting upwards and another to manage the downward tilt. ```js const scrollContainers = document.querySelectorAll('.side-scroll'); scrollContainers.forEach((container) => (container.scrollTopVH = 5)); //We need to move the scrollContainers a little bit in the beginning so they match the camera level function scrollDown() { scrollContainers.forEach((container, index) => { container.scrollTopVH += 0.2; if (container.scrollTopVH >= 8) { const activeDot = container.querySelector('.scroll-item-active .dot'); activeDot.getAnimations()[0].currentTime = 0; container.scrollTopVH = 5; } }); } function scrollUp() { scrollContainers.forEach((container, index) => { container.scrollTopVH -= 0.1; if (container.scrollTopVH <= 2) { const activeDot = container.querySelector('.scroll-item-active .dot'); activeDot.getAnimations()[0].currentTime = 0; container.scrollTopVH = 5; } }); } ``` In the code above, we adjust the `scrollTop` property of both `scrollContainers`. We then check if the `scrollTop` exceeds a certain threshold (or falls below it when the camera tilts up). If it does, we reset the `scrollTop` and the animations, creating a seamless infinite loop. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/camera-tilt/#controlling-the-gauge] ## Creating a camera tilt gauge: Controlling the gauge (2/2) There are a few things to note. The numbers used for the checks were tested specifically for this UI, so they may need to be adjusted for different use cases. Additionally, we take advantage of the `scrollTopVH` property available only in Gameface to avoid additional JavaScript operations and save on performance. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/camera-tilt/#integrating-with-your-game] ## Creating a camera tilt gauge: Integrating with Your Game In this example, we’ll integrate our camera tilt gauge into a sample game created with Unreal Engine. We’ll demonstrate the implementation using blueprints, building upon the logic of the Third Person base game in Unreal. For detailed instructions on integrating Coherent Gameface with Unreal Engine, refer to our previous articles. #### Sending the data from our game To achieve this, navigate to the ThirdPerson character blueprint and find the `EnhancedInputAction` event listener. Next, we’ll cast to our CoHTML object. In this example, we’ll use a plane, but it could also be a HUD. Next, we’ll use the Y value from the event to determine if the camera is tilting up or down and then send the corresponding event to our UI. #### Receiving the data in our UI With our JavaScript functions in place, we can now use the `engine.on` function to listen for the events and execute these functions accordingly. ```js engine.whenReady.then(() => { engine.on('cameraUp', scrollUp); engine.on('cameraDown', scrollDown); }); ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/camera-tilt/#in-conclusion] ## Creating a camera tilt gauge: In conclusion A camera tilt gauge enhances player awareness by providing real-time feedback on camera orientation. By using rotation-based calculations, UI animations, and smooth transitions, you can create an intuitive and responsive gauge for your game. Experiment with different styles and placements to best suit your game’s aesthetics and gameplay mechanics. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/carousel-with-perspective/] ## Carousel with Perspective ## Carousel with Perspective ui tutorials 3/28/2024 Tony Gruev 1. Layout of the Hero Item 1. Carousel Item Layout and Styles 2. Our Requirements 2. Carousel Component Integration 1. Setup Walkthrough 2. Usage 3. Carousel Interaction 4. Usage with Data Binding The Carousel component is popular and used in many games on various platforms. Creating a carousel menu in Gameface is straightforward using the [Carousel ](https://coherentlabs.github.io/GameUIComponents/en/components/carousel/)component, which can be customized to suit our requirements with minimal adjustments. Additionally, leveraging the [Data Binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/)feature in Gameface allows us to do dynamic initialization and visual modifications of the carousel menu. This is not a full guide covering every line of code, as the complete sample demonstrating carousel usage is accessible within the Gameface package. You can find it in the `${Gameface package}/Samples/uiresources/UITutorials/carousel-perspective directory`. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/carousel-with-perspective/#layout-of-the-hero-item] ## Carousel with Perspective: Layout of the Hero Item (1/2) Initially, we will focus on the design of how the carousel item will look - the layout and the styling of it. Then we are going to proceed with the integration of the carousel and its usage. #### Carousel Item Layout and Styles This is going to be the layout: ```html ``` Since we are going to have this layout in the carousel item slot, we named it accordingly and styled it: ```css .carousel-item { position: relative; width: 400px; height: 300px; background-image: url('../assets/item_background_bw.jpg'); background-repeat: no-repeat; border-radius: 7%; perspective: 800px; } ``` We are going to use `perspective` to achieve a nicer transition effect while navigating through the carousel menu.\ For the full styling, check the CSS file in *src/main.css*. #### Our Requirements We want a background that is going to change when an item is selected, an animation for the name of the hero and its avatar and have a class image for the hero. The inner elements of the `.carousel-item` are sized and positioned accordingly.\ Additionally, we are preparing for the animations to be added to the name and the avatar elements when changing the current carousel item. ```css .hero-name, .hero-avatar { transform: translateX(-50%) translateZ(0px); transition: transform 0.3s ease-in; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/carousel-with-perspective/#layout-of-the-hero-item] ## Carousel with Perspective: Layout of the Hero Item (2/2) As for the background, we are going to use the `.carousel-item` element by adding a `linear-gradient` as a second background. ```css .carousel-current-item .carousel-item { background-image: linear-gradient(rgba(0, 100, 170, 0.5), rgba(100, 100, 0, 0.5)), url('../assets/item_background_bw.jpg'); } ``` For the name and avatar there is going to be a simple transformation with `translateZ` to smoothly pop out those elements. ```css .carousel-current-item .hero-name, .carousel-current-item .hero-avatar { transform: translateX(-50%) translateZ(100px); } ``` The idea here is to dynamically set a class on a (carousel) wrapper and style accordingly when transitioning from one item to another and we are going to use the `.carousel-current-item` class for that. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/carousel-with-perspective/#carousel-component-integration] ## Carousel with Perspective: Carousel Component Integration (1/3) Since we are ready with our design, it is time to integrate, style and use the [Carousel ](https://coherentlabs.github.io/GameUIComponents/en/components/carousel/)component. #### Setup Walkthrough - Run `npm i` in the root folder of the sample which holds the **package.json** with the carousel component - In the html file *src/index.html* the component must be placed in the ``: ```html ``` #### Usage Now it is time to not only place our HTML layout in the carousel but also explain how to utilize the [Data Binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/)of Gameface. ##### Carousel Usage You can paste the layout we already created and duplicate as many items as you like in the `slot="carousel-slot"` element to try it out. ```html ``` If you only need the carousel (without the data binding), add only the layout we created and the carousel can be used in its full potential. #### Carousel Interaction We have added an event listener and used a function to toggle the `.carousel-current-item` class according to the current carousel item using the available Carousel `currentItemIndex` setter. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/carousel-with-perspective/#carousel-component-integration] ## Carousel with Perspective: Carousel Component Integration (2/3) ```js document.addEventListener('keydown', (event) => { const keyCode = event.keyCode; if (keyCode === 37) { changeCarouselCurrentItem(-1); } else if (keyCode === 39) { changeCarouselCurrentItem(1); } }); ``` For the full code - check the *src/index.js* file. #### Usage with Data Binding From now on we are proceeding with the additional properties we are going to need for the [Data Binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/). ```html ``` ##### Data Binding (Mocked) Model We need 2 more scripts to initialize and use the data binding provided with Gameface: ```html ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/carousel-with-perspective/#carousel-component-integration] ## Carousel with Perspective: Carousel Component Integration (3/3) In short, the *model.js* creates a JS (mocked) model with the heroes - their names and avatar and class image paths for the data binding to use. Make sure to check the use of [engine.createJSModel ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/#creating-the-attribute-handlers). Check the *src/index.js* file and also note the use of [engine.whenReady ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/javascript_native/#enginewhenready). So now when running the sample in the [Gameface Player ](https://docs.coherent-labs.com/cpp-gameface/quick_start/player/player/), the `data-bind-for` property is populating elements according to the model and setting the name for the hero and the class and avatar images. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/] ## Creating an interface for customizing character appearance ## Creating an interface for customizing character appearance ui tutorials 7/16/2024 Kaloyan Geshev 1. Prerequisites 2. Getting started 1. Creating the character 2. Setting up the live view 3. Defining the changeable character body parts 4. Create methods for changing body parts 5. Implementing Body Part Changes 6. Preserving the active index of the selected body part 7. Update the active body parts index 3. Creating the Frontend 1. Building the Character Customization Menu and Preview 4. Bonus - Rotating the character and focusing focusing on specific parts for customization 1. Adjusting the camera position for character customization 2. Rotating the character If you’ve already reviewed the tutorial on displaying 3d objects in the UI you’re familiar with the [Live Views ](https://docs.coherent-labs.com/cpp-gameface/integration/optional_features/liveviews_native/)feature. This feature allows rendering dynamic textures from the engine directly into the UI. Leveraging this powerful feature, this tutorial will guide you through creating a dedicated screen for changing a character’s appearance directly from the UI in the game. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#prerequisites] ## Creating an interface for customizing character appearance: Prerequisites For this tutorial we’ll be extending a sample that we have, called `Parallax UI` which utilizes `React 18` with `React Router 6`. Apart from that we’ll be using our component [scrollable container ](https://coherentlabs.github.io/GameUIComponents/en/components/scrollable-container/)and the [Interaction Manager library ](https://coherentlabs.github.io/GameUIComponents/en/interaction-manager/introduction/)to help with the keyboard interactions. For the 3D models we’ll use the free [Stylized Character Kit ](https://www.unrealengine.com/marketplace/en-US/product/stylized-male-character-kit-casual)assets. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#getting-started] ## Creating an interface for customizing character appearance: Getting started (1/5) For this project we are going to use `Unreal Engine 5.3` and with blueprints to update the game based on the UI interactions. We’ll be using an existing project with Gameface integrated, but you can also do it for a blank project, which can be set up by following the [documentation ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/). #### Creating the character First, we’ll create a `Blueprint Class` called `CharacterBP` to contain our 3D character model. Inside we’ll add a `SceneCaptureComponent2D` for the camera that renders onto our UI, along with an `Arrow` component that will hold the character’s mesh. The arrow will be used later for implementing logic to rotate the character. ##### Adding character meshes After completing the previous step, it’s time to add the character meshes to our blueprint: - After adding the Stylized Character Kit to your project, access its models by navigating to `All/Content/SCK_Casual01/Blueprints` in the `Content Browser` and opening the `ThirdPersonCharacter` blueprint. Copy the `Mesh (CharacterMesh0)` from there. * Open the `CharacterBP` created earlier and paste the mesh inside the `Arrow`. - Configure the `SkeletalMesh`: - Change the `Skeletal Mesh Asset` in the `Details` menu to one of the kit meshes, e.g `MESH_PC_03`. - Set the `Animation Mode` in the `Details` menu to `Use Animation Blueprint`. - Set the `Anim Class` in the `Details` menu to `ThirdPerson_AnimBP_C` to apply animations to the mesh. - Set the visibility of the `SkeletalMesh` to false. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#getting-started] ## Creating an interface for customizing character appearance: Getting started (2/5) This sets the default mesh for the character and enables animations via the `ThirdPerson_AnimBP_C` class. - Create new `SkeletalMesh` for each character parts that you want to enable for customization inside the `SkeletalMesh` created in the previous steps. For example create the `Chest`, `Head`, `Legs`, `Hands` and `Face`. * Setup the new meshes. Change the `Skeletal Mesh Asset`, `Animation mode` and `Animation Class` for each part as done previously for the `SkeletalMesh`. For example, for the chest: - Change the `Skeletal Mesh Asset` to one of the chest meshes, e.g., `MESH_T_01`. - Set the `Animation Mode` to `Use Animation Blueprint`. - Set the `Anim Class` to `ThirdPerson_AnimBP_C`. #### Setting up the live view In our case it’s pretty straightforward, we’ll follow the [guide in our documentation ](https://docs.coherent-labs.com/unreal-gameface/advanced-features/texturesinui/liveviews/). Since we’ll be showing the character in our UI, we’ll need to follow the second part of the tutorial in the documentation for [`Transparent Live Views` ](https://docs.coherent-labs.com/unreal-gameface/advanced-features/texturesinui/liveviews/#transparent-live-view-textures). **Ensure you place the `CharacterBP` onto the level map. Without this, nothing will render in our `RenderTarget`!** #### Defining the changeable character body parts In the `CharacterBP` blueprint, set arrays with options for changing the character’s body parts. We’ll demonstrate this for the chest options, but the process is the same for other parts. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#getting-started] ## Creating an interface for customizing character appearance: Getting started (3/5) - Create a new variable `ChestOptions` of type `Array of Skeletal Mesh Object References`. * Set the default value of `Chest Options` to include all customizable chests. In our example, the Stylized Character Kit provides 3 chests, so add 3 items and set their values to the corresponding chest meshes. - Repeat these steps for the face and legs to enable customization for these parts. #### Create methods for changing body parts We will create a method to change the current mesh for the chest. The steps are similar for other body parts. To do that create a new function inside the `CharacterBP` called `ChangeChest` with following definition: The method takes the new index for the chest from the previously defined array and updates it directly in the `Chest` mesh. #### Implementing Body Part Changes To change a character’s body part, we will subscribe to a custom event from the frontend, which will call the methods we created for changing a body part. We will follow the [UI Scripting with C++ ](https://docs.coherent-labs.com/unreal-gameface/integration/ui-scripting/jsinteractions/#ui-scripting-with-c)guide to define the custom event and make it usable in our blueprints. This event will have two arguments: - customizationType - **String**. Specifies the type of customization requested, either `Chest`, `Legs` or `Face`. - index - **Number**. The index of the item to use for the character’s appearance, defined in the `ChestOptions`, `FaceOptions`, or `LegsOptions` arrays from the previous steps. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#getting-started] ## Creating an interface for customizing character appearance: Getting started (4/5) To enable this, we will create a new C++ class extending the `CohtmlGameHUD` class defined by the Gameface Plugin. ```cpp #pragma once #include "CoreMinimal.h" #include "CohtmlGameHUD.h" #include "MyCohtmlGameHUD.generated.h" UCLASS() class AMyCohtmlGameHUD : public ACohtmlGameHUD { GENERATED_BODY() public: virtual void BeginPlay() override; UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = Gameplay) void CustomizeCharacterEvent(const FString& customizationType, const int index); private: UFUNCTION() void BindUI(); }; ``` Here we define the handler that will be executed when the JavaScript event `CustomizeCharacterEvent` is triggered. The implementation is as follows: ```cpp #include "MyCohtmlGameHUD.h" void AMyCohtmlGameHUD::BeginPlay() { Super::BeginPlay(); CohtmlHUD->ReadyForBindings.AddDynamic(this, &AMyCohtmlGameHUD::BindUI); } void AMyCohtmlGameHUD::BindUI() { CohtmlHUD->GetView()->RegisterForEvent("customizeCharacter", cohtml::MakeHandler(this, &AMyCohtmlGameHUD::CustomizeCharacterEvent)); } ``` In the `BindUI` method, we register the `customizeCharacter` event, which will be triggered from the frontend. Once the custom event is set up in C++, it can be accessed in the `coherentBP` blueprint. This allows us to use the event to change the character’s body part by setting up the following blueprint: By using the `Customization Type` argument, we can determine which character mesh should be replaced with a new one selected from the array by the given Index. #### Preserving the active index of the selected body part --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#getting-started] ## Creating an interface for customizing character appearance: Getting started (5/5) To allow the Frontend to know which item is selected for the `Chest`, `Face`, and `Legs`, we need to create a binding model that will be accessible in the UI. This will enable us to retrieve this information. To achieve this, we first need to define a structure called `CharacterSelectedParts` that will hold the active index for each customizable character part. For instance, if the chest with index 1 is currently selected, the `ChestIndex` should be set to 1. Once the structure is created, we need to create a binding model from it. To do this, we must wait for the `ReadyForBindings` event and then create the model. The blueprint below illustrates this process. #### Update the active body parts index After defining the struct for the active body part indexes, we need to update the model with the relevant active indexes whenever a character’s appearance changes. This involves enhancing the blueprint we’ve defined for changing the character’s appearance. Here, the `Character` variable refers to the `CharacterSelectedParts` struct. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#creating-the-frontend] ## Creating an interface for customizing character appearance: Creating the Frontend (1/3) In our Parallax UI project, we’ll create a new page called `Customize Character` and set it up to match the rest of the UI (we won’t delve into the styling details here). This page will have two main elements: one for the character customization menu with items for `Face`, `Chest`, and `Pants`, and another for displaying the character preview. #### Building the Character Customization Menu and Preview To create the customization menu, we’ll define the menu items directly in the React component. **Note that using our binding system is more efficient, but for simplicity, we’ll define the items directly here. Normally, you’d define the items model on the backend in Unreal and access it via data binding attributes.** ```jsx const [selectedMenu, setSelectedMenu] = useState(-1); const menus = [ { title: 'Face', items: [ './images/edit-character/face_0.png', ... ], }, { title: 'Chest', items: [ './images/edit-character/chest_0.png', ... ], }, { title: 'Legs', items: [ './images/edit-character/legs_0.png', ... ], }, ]; ``` We will have a state variable for the selected menu, used to toggle between customization menus, and a `menus` variable holding data for each menu. To map the state and data, we render the following template: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#creating-the-frontend] ## Creating an interface for customizing character appearance: Creating the Frontend (2/3) ```jsx
Customize character
{menus.map((menu, index) => { return (
{ selectMenu(event, index); }} className={`edit-character-item`}>
{menu.title}
{menu.items.map((itemImage, itemIndex) => { return (
{ engine.trigger(`customizeCharacter`, menu.title, itemIndex) }} style={{ backgroundImage: `url(${itemImage})` }} className={`edit-character-item-image`} data-bind-class-toggle={`edit-character-item-image-selected:{{CharacterSelectedParts.${menu.title}Index}} === ${itemIndex}`} >
) })}
) })}
``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#creating-the-frontend] ## Creating an interface for customizing character appearance: Creating the Frontend (3/3) Key Points to Note: 1. **Toggling Menus**: We toggle the menus by changing the selected menu index. ```jsx
{ selectMenu(event, index); }} className={`edit-character-item`}> ``` ```jsx const selectMenu = (event, menuIndex) => { if (event.target.classList.contains('edit-character-item-items') || event.target.classList.contains('edit-character-item-image')) return; if (selectedMenu === menuIndex) { setSelectedMenu(-1); return; } setSelectedMenu(menuIndex); } ``` The selectMenu method changes the selected menu index, closes the current menu if it’s selected and you click on it, and prevents toggling if you click on any child element. 2. **Active Class Toggle**: We use the `data-bind-class-toggle` attribute to set the active class to the item currently selected on the character. This utilizes the `CharacterSelectedParts` model created earlier. 3. **Triggering Customization Events**: When an item is clicked, we send the `customizeCharacter` event to the engine. ```jsx onClick={() => { engine.trigger(`customizeCharacter`, menu.title, itemIndex) }} ``` 4. **Character Preview**: We display the character preview using the live view we created. ```jsx ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#bonus---rotating-the-character-and-focusing-focusing-on-specific-parts-for-customization] ## Creating an interface for customizing character appearance: Bonus - Rotating the character and focusing focusing on specific parts for customization (1/4) #### Adjusting the camera position for character customization To adjust the camera position, we need to register a binding event in JavaScript that will trigger the camera repositioning. For example, we can register an event to focus on the character’s chest. First, cast the `SceneCaptureComponent2D` of the `CharacterBP` blueprint to `CohtmlGameHUD` and inform the HUD that it is ready for bindings. Next, register a binding event that is triggered by JavaScript. Let’s register an event called `focusChest`. Now, we need to change the camera’s position. Use the `Set Relative Location` method for the `SceneCaptureComponent2D` to do this. This will set the camera position to `(0,0,0)`. However, a smooth transition from the current camera position to the new one is preferable. To achieve this, define a method in `CharacterBP` called `getCameraPosition` that retrieves the current camera position, returning the `x`, `y`, and `z` coordinates. Then, create a smooth transition between the old and new camera positions. Use a timeline to interpolate each camera axis value from the old to the new one. In this example, we interpolate the `X` and `Z` values of the current camera position to `130` for the `X` and `25` for the `Z`. You can adjust these values to suit your needs and achieve the best visual result. Additionally, stop any timelines currently running for the camera. This prevents animation clashes when focusing on different parts of the character, such as the chest and legs simultaneously. Create a method to stop timelines for changing the camera position. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#bonus---rotating-the-character-and-focusing-focusing-on-specific-parts-for-customization] ## Creating an interface for customizing character appearance: Bonus - Rotating the character and focusing focusing on specific parts for customization (2/4) Here, `Timeline Face`, `Timeline Legs`, `Timeline Chest`, and `Timeline Initial` are references to the timelines that need to be stopped. Summarizing all these steps, the blueprint for `CharacterBP` will look like this: The blueprints for focusing on the face, legs, and initial camera position are: After completing the engine setup, trigger these binding events from the frontend. First, modify the menu’s data structure by adding a `focusCallback` property: ```diff const menus = [ { title: 'Face', items: [...], focusCallback: () => engine.trigger("focusFace"), }, ... ]; ``` After making these changes, call the `focusCallback` of the menu when it is selected: ```diff const selectMenu = (event, menuIndex) => { ... if (selectedMenu === menuIndex) { setSelectedMenu(-1); engine.trigger("initialFocus"); return; } setSelectedMenu(menuIndex); menus[menuIndex].focusCallback(); } ``` Following these steps will result in this: #### Rotating the character In the tutorial about the 3D objects in the UI, we’ve set up a method for rotating our character. We will enhance this rotation by adding functionality to rotate the character using both the mouse and the keyboard. First, we need to listen for rotate left/right events in our backend. This is configured in the `CharacterBP` as follows: Once configured, you can trigger these events through keyboard actions or when the mouse is dragged left or right. ##### Rotate character with the keyboard For keyboard rotation, refer to the setup in this tutorial. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#bonus---rotating-the-character-and-focusing-focusing-on-specific-parts-for-customization] ## Creating an interface for customizing character appearance: Bonus - Rotating the character and focusing focusing on specific parts for customization (3/4) Simply replace the backend-triggered events—such as `engine.trigger("rotateCameraLeft")`; with `engine.trigger("characterRotateLeft");` and do the same for right rotation. ##### Rotate character with the mouse To enable character rotation with the mouse, follow these steps: 1. Add a mouse down event to the live view element. 2. Add a mousemove event to the document that triggers `characterRotateLeft` and `characterRotateRight` events to the backend. 3. Finally, clear the events. The handlers definitions for dragging starts, stops, and continues are the following: ```jsx let isDragging = false; let initialMouseX = 0; const startDragging = (event) => { if (isDragging) return; isDragging = true; initialMouseX = event.clientX; document.addEventListener('mousemove', dragModel); document.addEventListener('mouseup', stopDragging); } const dragModel = (event) => { if (event.clientX < initialMouseX) { engine.trigger("characterRotateLeft"); initialMouseX = event.clientX; return; } if (event.clientX > initialMouseX) { engine.trigger("characterRotateRight"); initialMouseX = event.clientX; } } const stopDragging = (event) => { document.removeEventListener('mousemove', dragModel); document.removeEventListener('mouseup', stopDragging); isDragging = false; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-customization/#bonus---rotating-the-character-and-focusing-focusing-on-specific-parts-for-customization] ## Creating an interface for customizing character appearance: Bonus - Rotating the character and focusing focusing on specific parts for customization (4/4) To determine if the mouse is being dragged left or right, use the `event.clientX` property and compare it to the initial position. Trigger the appropriate rotate event to the backend and update the initial position with the current one: `initialMouseX = event.clientX;`. And finally to enable dragging on the live view element, add the event in the `useEffect` method: ```jsx const model = useRef(null); ... useEffect(() => { ... model.current.addEventListener('mousedown', startDragging); return () => { model.current && model.current.removeEventListener('mousedown', startDragging); ... }; }, []); ``` ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/] ## Creating screen for character selection ## Creating screen for character selection ui tutorials 10/29/2024 Kaloyan Geshev 1. Overview 2. Resources 3. Getting started - Unreal Engine 1. Adding camera actors for each character 2. Create a HUD class blueprint 3. Setting up the view and the input 4. Change the HUD class 5. Initializing the camera actors 6. Creating a method to change the active camera 7. Implementing character switching 8. Register events for changing the active character 9. Create the data bind model 10. Setting the active character data 4. Getting started - Frontend 1. Import cohtml.js 2. Displaying the character’s name 3. Add logic for switching characters 4. Adding arrows for character switching 5. Show the stats of the character 6. Fill the stat progress bar 7. Animate the text showing the stat value 5. Full source of the tutorial In the character selection screen, players are invited to choose their hero for the journey ahead. Each character comes with unique abilities, strengths, and playstyles, allowing players to find the perfect match for their strategy. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#overview] ## Creating screen for character selection: Overview In this tutorial, we’ll use `Unreal Engine v5.3` and blueprints to design a level where players can pick different characters. While it’s possible to implement this using live views as shown in previous tutorials, we’ll now explore a more dynamic and engaging character selection method. When the player cycles through characters, they will be displayed directly in the game, using different camera views to showcase each character. For the UI we will use the Gameface’s [native ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/)and [UE ](https://docs.coherent-labs.com/unreal-gameface/integration/ui-scripting/databinding/)data-binding features to bind game data to the UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#resources] ## Creating screen for character selection: Resources - Character models:[ Paragon: Revenant ](https://www.unrealengine.com/marketplace/en-US/product/paragon-revenant). - Environment assets: [Paragon: Agora and Monolith Environment ](https://www.unrealengine.com/marketplace/en-US/product/paragon-agora-and-monolith-environment). - Icon: [Cracked alien skull icon ](https://game-icons.net/1x1/lorc/cracked-alien-skull.html). - Font: [Jacksonville ](https://www.dafont.com/jacksonville-3.font?text=health). --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---unreal-engine] ## Creating screen for character selection: Getting started - Unreal Engine (1/6) We’ll begin by setting up the project in Unreal Engine. Use the [getting started ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/)guide from our documentation to install the Gameface plugin and integrate it into an existing project or use the sample project created by the installer. After setting things up, we’ll arrange and design the world in our level. You can use your creativity and the free assets linked in the Resources section to place them in your world. For this tutorial, we arranged the assets in the following way: #### Adding camera actors for each character Once your game world is ready, we’ll begin building the character selection system. The first step is to create a camera actor for each character the player can choose from. To create a camera actor, use the menu to create objects and search for `Camera Actor`. After selecting the object, place it appropriately in the world. In our case, the character will be displayed on the right side of the screen, with their stats on the left. Make sure to position the cameras consistently across characters: **Note:** Be sure to uncheck the `Constrain Aspect Ratio` setting to ensure the camera’s aspect ratio matches the screen. Feel free to adjust the `Location`, `Rotation`, and `Scale` of the camera to achieve precise positioning. #### Create a HUD class blueprint --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---unreal-engine] ## Creating screen for character selection: Getting started - Unreal Engine (2/6) Now that the cameras are positioned, it’s time to implement the character selection logic. We’ll create a HUD class blueprint to handle the level’s logic. Start by creating the `CohCharacterBP`, inheriting from the `CohtmlGameHUD` class: #### Setting up the view and the input Create a `Setup Input` method in `CohCharacterBP` to enable user input for the UI: To initialize our `HTML` page for the UI, setup the view and set the input to the view in the `CohCharacterBP` blueprint. #### Change the HUD class To display the game’s UI as defined in our `HTML` page, we need to set the game’s HUD class. This is done via the `Game Mode` in the `World Settings`. #### Initializing the camera actors With the view set, the next step is to implement the logic for switching cameras as the player selects different characters. Start by creating a `Character cameras` variable in `CohCharacterBP`, that is an array of `Camera Actor` types. Next, populate this variable by using the `Get All Actors Of Class` method to retrieve all camera actors in the world and assign them to the `Character cameras` array. #### Creating a method to change the active camera To switch the camera, we’ll create a `setActiveCamera` method that will handle changing the active camera based on the player’s selection. First, create a `Current character` variable, that will hold the index of the currently selected character. Set it to `0` by default to represent the index of the first character. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---unreal-engine] ## Creating screen for character selection: Getting started - Unreal Engine (3/6) The `setActiveCamera` method will retrieve the camera of the currently selected character from the `Character cameras` array and switch the active camera using the `Set View Target with Blend` method. This method transitions between cameras over a set `Blend Time`, which we’ll set to 0.5 for a smooth 500ms transition. Ensure that the `Lock Outgoing` option is checked for the `Set View Target With Blend` method. Once the `setActiveCamera` method is created, call it in the Event Graph to switch to the first character’s camera when initializing the `Character cameras`. #### Implementing character switching To switch between characters, we’ll create a `changeActiveCharacter` method, which will accept a boolean input - `direction`, indicating whether the player is cycling forward (true) or backward (false) through the character list. The method will update the `Current character index` accordingly. When moving forward, we’ll check if the index exceeds the length of the `Character cameras` array, and if so, reset it to `0` (first character). Similarly, when moving backward, if the index is less than `0`, we reset it to the index of last character in the array. Finally, call the `setActiveCamera` method to change the camera to the next or previous character. #### Register events for changing the active character We will set up two events to handle character selection: one for switching to the next character and another for the previous character. These events will be named `nextCharacter` and `prevCharacter`, and they’ll be triggered from the UI we’ll implement later. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---unreal-engine] ## Creating screen for character selection: Getting started - Unreal Engine (4/6) To add these events in our `CohCharacterBP`, we need to wait for Gameface to be ready for bindings using the `Bind Events Ready for Bindings` method. After that, we can register the two events using the `Register for Event` method, which accepts the `Java Script Event Name` where we’ll specify our event names. For both events, we will call the previously created `Change Active Character` method, adjusting the `Direction` property to `true` or `false` based on whether we’re moving to the previous or next character. #### Create the data bind model Now that we’ve set up the logic for changing the active character and registered the events, it’s time to add a data model for the game’s characters. This model will be linked with the UI so that when a character is changed, the UI updates automatically. Each character in our game will have a name and stats. The stats will be an array of objects, with each object containing a stat name and its value. First, we’ll create a structure defining the stat object, named `Stat`. Each stat will include a name as a string and its current value as an integer. Next, we’ll create a `Character Model` structure to store the character’s name and stats. The name will be a string, and the stats will be an array of `Stat` objects. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---unreal-engine] ## Creating screen for character selection: Getting started - Unreal Engine (5/6) Now, in the event graph of our `CohCharacterBP`, we’ll create a variable called `Characters`, which will be an array of `Character Model` items. We’ll set a default value for this array with three items, as we have three characters in our case. Each character will have a name and the following stat categories: `health`, `strength`, `defense`, `attackPower`, `magicPower`, and `stamina`. For each stat the values should range from 0 to 100. Once the `Characters` variable is defined, we’ll create an `Active Character` variable of type `Character Model` to store the name and stats of the currently active character. This variable will be bound to the UI. Now that we’ve set up the `Active Character`, we can bind it to the UI. After registering the two events in our blueprint, we’ll populate it with the current character data, retrieved from the `Characters` array using the `Current Character` index. Finally, we’ll create a data model from the `Active Character` structure using the `Create Data Model From Struct` method and synchronize the models with the `Synchronize Models` method. We’ll name this model `Character`, which allows us to access it from the frontend. #### Setting the active character data The final step in the `CohCharacterBP` implementation is to update the model for the active character, ensuring the UI receives the correct data when the player changes characters. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---unreal-engine] ## Creating screen for character selection: Getting started - Unreal Engine (6/6) To do this, we’ll create a new method called `Set Active Character`, which will retrieve the current character data from the `Characters` array, set it to the `Active Character`, and then update the model using the `Update Whole Data Model from Struct` method. After the model has been updated we need to synchronize the UI with the model via the `Synchronize Models` method. After creating this method, we can call it whenever the user changes the active character, ensuring that the character model is updated after the active camera is changed in the `Change Active Character` method created earlier. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (1/8) Once the game logic is fully implemented in the `CohCharacterBP`, it’s time to build the UI and bind it to the game data. We’ll begin by creating an `index.html` file in the `uiresources` folder. #### Import cohtml.js To enable communication between the UI and the game, the `cohtml.js` library must first be imported. ```html ``` #### Displaying the character’s name Next, we’ll display the current character’s name. This can be easily achieved using the `data-bind-value` attribute. ```html
``` #### Add logic for switching characters We’ll create a new `JavaScript` file and import it into our `HTML` page. Make sure to include this file after the `cohtml.js` script. ```html
``` To allow players to change characters, in `index.js`, we’ll define two methods, `changePrev` and `changeNext`, that will switch between characters. Additionally, we’ll add a listener for the `keydown` event, allowing players to use the left and right arrow keys for navigation. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (2/8) ```js function changePrev() { engine.trigger('prevCharacter'); } function changeNext() { engine.trigger('nextCharacter'); } document.addEventListener('keydown', (event) => { if (event.keyCode === 37) changePrev(); if (event.keyCode === 39) changeNext(); }); ``` #### Adding arrows for character switching Although arrow keys allow character switching, it’s helpful to add on-screen arrows for this purpose. We’ll place these on either side of the character name and wrap everything in an element with class - `controls`. ```html
<
>
``` In the end, the result will look like this: #### Show the stats of the character To show character stats, we’ll again use data binding attributes. For each stat, we’ll display a label for the stat name, a progress bar made of skull icons, and the stat value as text to the right of the bar. The label will be bound using the `data-bind-value` attribute. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (3/8) For the progress bar, we’ll use `data-bind-style-background-position-x`, which will adjust the background’s X-axis position, simulating the skulls filling up based on the stat value. We’ll also use `data-bind-class-toggle` to change the background color based on the value: red for values below 25, yellow for values between 25 and 50, and white for values above 50. For the stat value text, we’ll implement a custom binding attribute, `data-bind-progress`, to animate the text representing the stat value. Finally, we’ll use the `data-bind-for` attribute to generate all the character stats dynamically, reducing repetitive code. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (4/8) ```html
<
>
``` #### Fill the stat progress bar To fill the progress bar, we’ll use a mask image with a linear gradient background in the `stat-value-data` CSS class. The mask will be an SVG of five skulls, and the background will be controlled by classes `bg-red`, `bg-white`, and `bg-yellow`. These classes define a gradient that changes from filled (50%) to unfilled based on the stat value. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (5/8) For the mask image we will use the following svg that was created with the help of the skull icon linked in the resources section: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (6/8) ```html ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (7/8) And the styles for the progress bar will be: ```css .bg-red { background: linear-gradient(90deg, rgb(255 0 0) 0%, rgb(255 0 0) 50%, rgb(100, 100, 100) 50%, rgb(100, 100, 100) 100%); } .bg-white { background: linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 50%, rgb(100, 100, 100) 50%, rgb(100, 100, 100) 100%); } .bg-yellow { background: linear-gradient(90deg, rgb(255, 255, 55) 0%, rgb(255, 255, 55) 50%, rgb(100, 100, 100) 50%, rgb(100, 100, 100) 100%); } .stat-value-data { flex: 1 0 0; height: 100%; mask-image: url(./Vector.svg); mask-size: 100% 100%; mask-position: 0% 50%; mask-repeat: no-repeat; background-size: 200% 100%; background-position: 50% 0; transition: background-position 500ms ease-out, background-image 500ms ease-out; } ``` #### Animate the text showing the stat value We’ll animate the stat value text so it dynamically updates while switching between characters. To achieve this, we’ll create a custom `data-bind-progress` attribute in `index.js` that smoothly increments or decrements the stat value over time. The animation works by: 1. Calculating the difference between the old and new stat value. 2. Setting an interval to increment or decrement the value over time, simulating the stat change. 3. Clearing the interval once the value matches the new stat or if time of 500ms exceeds. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#getting-started---frontend] ## Creating screen for character selection: Getting started - Frontend (8/8) ```js class Progress { constructor() { this.textValueChangeInterval = null; this.textValueChangeTimeout = null; } init(element, model) { this.value = model; this.currentValue = this.value; this.textElement = element; this.textElement.textContent = `${this.currentValue}/100`; } animateText() { if (this.textValueChangeInterval) clearInterval(this.textValueChangeInterval); if (this.textValueChangeTimeout) clearInterval(this.textValueChangeTimeout); const diff = this.value < this.currentValue ? this.currentValue - this.value : this.value - this.currentValue; if (!diff) return; const intervalTime = parseInt(500 / diff); this.textValueChangeInterval = setInterval(() => { if (this.currentValue === this.value) return clearInterval(this.textValueChangeInterval); if (this.value < this.currentValue) this.currentValue--; if (this.value > this.currentValue) this.currentValue++; this.textElement.textContent = this.value < this.currentValue ? `${this.currentValue}/100` : `${this.currentValue}/100`; }, intervalTime); this.textValueChangeTimeout = setTimeout(() => { clearInterval(this.textValueChangeInterval); this.currentValue = this.value; this.textElement.textContent = `${this.currentValue}/100`; }, 500); } update(element, model) { this.value = model; this.animateText(); } } engine.registerBindingAttribute('progress', Progress); ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#full-source-of-the-tutorial] ## Creating screen for character selection: Full source of the tutorial (1/5) The complete source code for this tutorial is available below, including additional styles used to enhance the UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#full-source-of-the-tutorial] ## Creating screen for character selection: Full source of the tutorial (2/5) ```html
<
>
``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#full-source-of-the-tutorial] ## Creating screen for character selection: Full source of the tutorial (3/5) ```css @font-face { font-family: jacksonvile; src: url(./Jacksonville.ttf); } body { width: 100vw; height: 100vh; margin: 0; font-family: jacksonvile; } .wrapper { width: 100vw; height: 100%; display: flex; justify-content: flex-end; flex-direction: column; background-image: linear-gradient(79deg, rgba(0, 0, 0, 0.8) 10%, rgba(0, 0, 0, 0.6) 38%, rgba(255, 255, 255, 0) 55%); visibility: visible; animation: in-left 500ms ease-in forwards; } @keyframes in-left { 0% { transform: translateX(-100vw); } 100% { transform: translateX(0); } } .stat-name { color: white; font-size: 5vw; text-shadow: 10px 10px 20px black; } .stats { width: 50%; position: relative; display: flex; font-size: 2.3vw; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 2vw; } .controls { width: 50%; display: flex; align-items: center; flex-direction: row; justify-content: space-between; transform: scale(0) rotateZ(-7deg) translateX(3vw) translateY(-4vw); animation: scale 300ms 500ms ease-in forwards; } @keyframes scale { 0% { transform: scale(0) rotateZ(-7deg) translateX(3vw) translateY(-4vw); } 100% { transform: scale(1) rotateZ(-7deg) translateX(3vw) translateY(-4vw); } } .stat { width: 50%; height: 2.5vw; margin: 0.5vw; display: flex; align-items: center; flex-direction: row; justify-content: space-between; } .arrow { font-size: 4vw; transition: transform 300ms; transform-origin: center center; transform: scale(1); color: white; cursor: pointer; } .arrow:hover { transform: scale(1.5); } .stat-label { color: white; flex-basis: 9vw; text-align: right; margin-right: 1vw; transition: color 500ms ease-out; } .stat-value { flex: 1 0 0; height: 70%; } .stat-value-text { height: 100%; width: 5.5vw; padding-left: 0.8vw; font-size: 2vw; color: white; font-weight: bold; align-items: center; } .bg-red { background: linear-gradient(90deg, rgb(255 0 0) 0%, rgb(255 0 0) 50%, rgb(100, 100, 100) 50%, rgb(100, 100, 100) 100%); } .bg-white { background: linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 50%, rgb(100, 100, 100) 50%, rgb(100, 100, 100) 100%); } .text-red { color: rgba(202, 22, 13, 1); } .bg-yellow { background: linear-gradient(90deg, rgb(255, 255, 55) 0%, rgb(255, 255, 55) 50%, rgb(100, 100, 100) 50%, rgb(100, 100, 100) 100%); } .text-yellow { color: rgba(255, 243, 0, 1); } .stat-value-data { flex: 1 0 0; height: 100%; mask-image: url(./Vector.svg); mask-size: 100% 100%; mask-position: 0% 50%; mask-repeat: no-repeat; background-size: 200% 100%; background-position: 50% 0; transition: background-position 500ms ease-out, background-image 500ms ease-out; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#full-source-of-the-tutorial] ## Creating screen for character selection: Full source of the tutorial (4/5) ```js class Progress { constructor() { this.textValueChangeInterval = null; this.textValueChangeTimeout = null; } init(element, model) { this.value = model; this.currentValue = this.value; this.textElement = element; this.textElement.textContent = `${this.currentValue}/100`; } animateText() { if (this.textValueChangeInterval) clearInterval(this.textValueChangeInterval); if (this.textValueChangeTimeout) clearInterval(this.textValueChangeTimeout); const diff = this.value < this.currentValue ? this.currentValue - this.value : this.value - this.currentValue; if (!diff) return; const intervalTime = parseInt(500 / diff); this.textValueChangeInterval = setInterval(() => { if (this.currentValue === this.value) return clearInterval(this.textValueChangeInterval); if (this.value < this.currentValue) this.currentValue--; if (this.value > this.currentValue) this.currentValue++; this.textElement.textContent = this.value < this.currentValue ? `${this.currentValue}/100` : `${this.currentValue}/100`; }, intervalTime); this.textValueChangeTimeout = setTimeout(() => { clearInterval(this.textValueChangeInterval); this.currentValue = this.value; this.textElement.textContent = `${this.currentValue}/100`; }, 500); } update(element, model) { this.value = model; this.animateText(); } } engine.registerBindingAttribute('progress', Progress); function changePrev() { engine.trigger('prevCharacter'); } function changeNext() { engine.trigger('nextCharacter'); } document.addEventListener('keydown', (event) => { if (event.keyCode === 37) changePrev(); if (event.keyCode === 39) changeNext(); }); ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/character-selection/#full-source-of-the-tutorial] ## Creating screen for character selection: Full source of the tutorial (5/5) ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/charts/] ## Charts in Game UI ## Charts in Game UI ui tutorials 6/6/2024 Veneta Kochovska, Kaloyan Geshev 1. Showcase overview 1. Source location 2. Sample specifics 1. Importing the d3.js library 2. d3.js charts 3. Chart data 4. Gameface components 5. Updating the range of each chart Charts within a game UI are essential for displaying various statistics, such as resource changes over time, leadership standings, and player attributes like accuracy, kills, deaths, and wins. Gameface supports [d3 ](https://d3js.org/), a JavaScript library for creating and manipulating SVG elements for data visualization. You can build and customize various charts using its low-level [API ](https://d3js.org/api). **Currently Gameface has full support for version 4 and below of the D3JS library. Newer versions have only partial support so the examples shown in this tutorial may not work with it.** --- [SOURCE: https://coherent-labs.com/blog/uitutorials/charts/#showcase-overview] ## Charts in Game UI: Showcase overview In this example, we created a window that presents data through various charts made with d3.js. We have implemented a line chart, bar chart, and pie chart displaying data about gold per year. Additionally, we have an area chart that shows all resources over the period between 0 and 1000 years. Each chart includes a range slider below it, allowing you to adjust the displayed data period and showing you how to manipulate the shown data in real time. #### Source location You can review the complete sample source within the `${Gameface package}/Samples/uiresources/UITutorials/StatisticsScreen` directory. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/charts/#sample-specifics] ## Charts in Game UI: Sample specifics (1/2) #### Importing the d3.js library The easiest way to import d3 is by using their provided CDNs (Content Delivery Network). ```html ``` #### d3.js charts We used some pre-made examples from the [d3-graph-gallery ](https://d3-graph-gallery.com/index.html)and adapted them for our demo needs. If you’re not familiar with the `d3.js` library, please refer to the documentation on their website before customizing the charts. - [Line chart](https://d3-graph-gallery.com/graph/line_change_data.html) - [Bar chart](https://d3-graph-gallery.com/graph/barplot_button_data_hard.html) - [Area chart](https://d3-graph-gallery.com/graph/stackedarea_template.html) - [Pie chart](https://d3-graph-gallery.com/graph/pie_changeData.html) For each chart, we created a separate file that creates the chart and has an update method to refresh the chart based on new data and range. You can check `src/areaChart.js`, `src/barChart.js`, `src/lineChart.js`, and `src/pieChart.js`. #### Chart data Random data generation is handled in the `src/generateData.js` file. The `generateChartData` method regenerates the data based on the year range and specified labels. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/charts/#sample-specifics] ## Charts in Game UI: Sample specifics (2/2) ```javascript function generateChartData(labels, yearsRange) { const chartData = []; const years = generateYearsFromRange(yearsRange); for (let i = 0; i < years.length; i++) { const yearData = { year: years[i] }; for (const label of labels) { const el = generatedData[label].find((el) => el.year === yearData.year); yearData[label] = el ? el.value : '0'; } chartData.push(yearData); } return chartData; } ``` For example, to get the data for `gold` from year `500` to `1000`, you would call the method like this: ```javascript generateChartData(['gold'], [500, 1000]); ``` #### Gameface components In the sample, we also used various Gameface components such as [`gameface-tabs` ](https://coherentlabs.github.io/GameUIComponents/en/components/tabs/), [`gameface-grid` ](https://coherentlabs.github.io/GameUIComponents/en/components/grid/), [`gameface-scrollable-container` ](https://coherentlabs.github.io/GameUIComponents/en/components/scrollable-container/), and [`gameface-rangeslider` ](https://coherentlabs.github.io/GameUIComponents/en/components/rangeslider/)to create a more structured and appealing UI. #### Updating the range of each chart We used the `gameface-rangeslider` component with the `two-handles` configuration to define the period from and to a specific year. We listen for the `sliderupdate` event. When its value changes, the corresponding chart data is regenerated, and the chart’s `.update` method is called with the new data for the specified range. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/] ## Making chat with emojis in Gameface ## Making chat with emojis in Gameface ui tutorials 5/30/2024 Kaloyan Geshev 1. 1/28/2025 Update 2. Showcase overview 1. Source location 3. Sample specifics 1. Chat messages container and buttons 2. Sending messages 3. Receiving messages 4. Server 5. Chat emojis - Model 6. Chat emojis (FE) - Emojis panel 7. Chat emojis (BE) - Resolving emojis 8. Chat user connected and disconnected 4. Styles Creating a chat in Gameface is a straightforward process, thanks to the built-in support for websockets. This is especially true when utilizing a library like [socket.io ](https://socket.io/). We have a [topic ](https://docs.coherent-labs.com/cpp-gameface/content_development/pages_guides/chatsocketio/)in our documentation that explains how the official socket.io [chat sample ](https://socket.io/get-started/chat/)works seamlessly in Gameface. #### 1/28/2025 Update **In version 1.61, Gameface adds support for certain types of emoji fonts. As this tutorial shows how to do chat emojis with `SVG` you may also want to know how to do it with an emoji font instead. You can check the guide inside the Emoji support news page for further information.** --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/#showcase-overview] ## Making chat with emojis in Gameface: Showcase overview In this showcase, we have enhanced the socket.io chat sample by adding several features: - A scrollable container for messages, using the Gameface scrollable-container [component ](https://coherentlabs.github.io/GameUIComponents/en/components/scrollable-container/), as Gameface does not natively support a scroll slider. - Connect and disconnect user messages displayed in the chat. - Timestamps for all messages. - Displaying the user ID for incoming messages. - A panel for sending emojis in the chat. This sample focuses on how to send and show emojis in the chat, as Gameface does not currently support OS emojis natively. And it has the added bonus of allowing you to use your own custom emojis. One straightforward method is to use SVG emojis. For this sample, we used a small set of SVG emojis from [OpenMoji ](https://openmoji.org/)to demonstrate the simplest way of adding emoji support to a chat in Gameface. #### Source location You can review the complete sample source within the `${Gameface package}/Samples/uiresources/UITutorials/ChatEmojis` directory. To run the sample, follow these steps: 1. Do `npm i` in this directory. 2. Run the chat server by executing `node server.js` in this directory. 3. Open two or more instances of Gameface and chat between them. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/#sample-specifics] ## Making chat with emojis in Gameface: Sample specifics (1/6) #### Chat messages container and buttons We followed the socket.io sample to create the messages container and the send button. We then enhanced it by adding scroll functionality to the messages container using the `gameface-scrollable-container` and included a button for toggling the emoji panel. ```html
    ``` #### Sending messages To send the text typed in the chat input to the server, an event is emitted when the `Send` button is clicked or when the `Enter` key is pressed while the input is focused. ```javascript const socket = io(); document.querySelector('.send-btn').addEventListener('click', () => { if (input.value) { socket.emit('chat message', input.value); input.value = ''; } }); input.addEventListener('keydown', (event) => { if (event.keyCode === 13 && input.value) { socket.emit('chat message', input.value); input.value = ''; } }); ``` After the server processes the message, it emits an event to all connected users, updating their chat UI. Check the next section for details. #### Receiving messages --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/#sample-specifics] ## Making chat with emojis in Gameface: Sample specifics (2/6) Receiving messages from the server on the front end involves subscribing to a `socket` event: ```javascript socket.on('chat message', ({ msg, id }) => { const item = document.createElement('li'); if (id === socket.id) item.classList.add('right'); item.innerHTML = (id !== socket.id ? `
    ${id}
    ` : '') + msg; messages.appendChild(item); if (id === socket.id) { waitForFrames(() => messagesContainer.onScrollSlider({ detail: { handlePosition: 100 } }), 7); } }); ``` This code creates a new `list` element to hold the message from the server, including the user ID if the message is from another user. The element is appended to the messages container, and if the message is from the current user, the scrollable container scrolls to the bottom. ```javascript if (id === socket.id) { waitForFrames(() => messagesContainer.onScrollSlider({ detail: { handlePosition: 100 } }), 7); // Scrolls the slider and container to 100% where the last message is } ``` `Know issue:` **There is a need to wait for 7 frames to ensure the scrollable container correctly scrolls to the last message. The scrollable container automatically resizes when a new `list` element is appended, which takes about 6 frames. Without waiting, the container might not scroll properly.** The `waitForFrames` function is defined as follows: ```javascript function waitForFrames(callback, frames) { if (frames === 0) return callback(); frames--; requestAnimationFrame(() => this.waitForFrames(callback, frames)); } ``` #### Server --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/#sample-specifics] ## Making chat with emojis in Gameface: Sample specifics (3/6) On the server side, messages sent from the front end are processed by listening for `socket` events. ```javascript const express = require('express'); const app = express(); const http = require('http'); const server = http.createServer(app); const { Server } = require("socket.io"); const io = new Server(server); io.on('connection', (socket) => { socket.on('chat message', (msg) => { const d = new Date(); const timeStamp = [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/') + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':'); io.emit('chat message', { msg: `
    ${msg}
    ${timeStamp}
    `, id: socket.id }); }); }); ``` A timestamp is generated for each message. The server then emits an event to the front end with the processed message in HTML format, along with the sender’s ID. #### Chat emojis - Model To simplify the instantiation of all emojis in a panel, we defined an array as a Gameface data binding model. Leveraging Gameface’s [data binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/), we can easily iterate over this model and display the emojis in the HTML page. The model is structured as follows: ```javascript const emojis = [ '/assets/emojis/1F600.svg', '/assets/emojis/1F601.svg', '/assets/emojis/1F602.svg', ... ]; ``` #### Chat emojis (FE) - Emojis panel --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/#sample-specifics] ## Making chat with emojis in Gameface: Sample specifics (4/6) We added a button to the right of the chat input that opens a panel with all supported chat emojis, allowing users to add emojis to their messages before sending them. Selecting an emoji from the panel inserts its code into the message input, surrounded by colons. For example, `:1:`. The panel was created using the [gameface-tooltip ](https://coherentlabs.github.io/GameUIComponents/en/components/tooltip/)component to wrap the emojis in a panel, and the [gameface-scrollable-container ](https://coherentlabs.github.io/GameUIComponents/en/components/scrollable-container/)component to enable scrolling if the emojis overflow the panel. ```html
    ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/#sample-specifics] ## Making chat with emojis in Gameface: Sample specifics (5/6) Here, we use data binding to render the emoji SVGs in the panel with `data-bind-style-background-image-url="{{iter}}"`, which sets the background of the div to the emoji URLs from the model. **Note: The tooltip might not be positioned correctly as its target is at the bottom right of the page. To fix this, override the tooltip’s `transform` property:** ```css .emojis-panel { ... transform: translateX(-70%) translateY(-105%) !important; ... } ``` #### Chat emojis (BE) - Resolving emojis When a message is received on the server, any emoji codes in the message should be resolved. To achieve this, extend the source in the Server section. ```javascript const emojis = require('./src/emojisMapServer'); io.on('connection', (socket) => { socket.on('chat message', (msg) => { const newMessage = msg.replace(/:[0-9]*:/g, (match) => { const emojiCode = match.replace(/:/g, ''); // Retrieve the emoji code between the : symbols. For example, :1: corresponds to the emoji with index 1 in our array of emoji URLs. return ``; }); const d = new Date(); const timeStamp = [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/') + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':'); io.emit('chat message', { msg: `
    ${newMessage}
    ${timeStamp}
    `, id: socket.id }); }); }); ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/chat-emojis/#sample-specifics] ## Making chat with emojis in Gameface: Sample specifics (6/6) Here, `newMessage` contains the processed message with all emoji codes replaced by `img` elements with the corresponding emoji SVG URLs from the emojis map. #### Chat user connected and disconnected Additionally, we added messages indicating when a user connects or disconnects from the chat. This is easily handled on the server side: ```javascript io.on('connection', (socket) => { io.emit('user connected', socket.id); ... socket.on('disconnect', () => { io.emit('user disconnected', socket.id); }); }); ``` On the front end, we handle the emitted events by subscribing to the `user connected` and `user disconnected` events and reading the user ID: ```javascript function setUserState(id, connected) { const item = document.createElement('li'); item.textContent = `User ${id} ${connected ? 'connected' : 'disconnected'}!`; messages.appendChild(item); } socket.on('user connected', (id) => setUserState(id, true)); socket.on('user disconnected', (id) => setUserState(id, false)); ``` For each connection or disconnection, we append a `list` item to the messages container. #### Styles To check the chat styles, refer to the `${Gameface package}/Samples/uiresources/UITutorials/ChatEmojis/styles.css` file. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/curved-hud/] ## How to create a Fish-eyed using a curved plane ## How to create a Fish-eyed using a curved plane ui tutorials 2/9/2025 Mihail Todorov 1. Setting up our game 2. Adding the CoHTML Plane to our character 3. Changing the plane mesh 4. In conclusion A well-designed HUD can enhance a player’s immersion, and a fish-eye effect can add a dynamic, stylized look to your game. Whether you’re aiming for a futuristic, distorted interface or a more subtle curved display, this guide will walk you through the techniques needed to implement a fish-eye HUD . In this tutorial, we’ll explore a method to create a curved HUD using Gameface’s in-world UIs. This technique allows us to project our UI onto any three-dimensional surface. Specifically, we’ll design a curved plane that distorts the UI to create a fish-eye effect. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/curved-hud/#setting-up-our-game] ## How to create a Fish-eyed using a curved plane: Setting up our game We’ll start with Unreal’s Base Third Person game template and reposition the camera to align with the character’s head. This setup allows us to seamlessly switch between first-person and third-person perspectives. While our focus is on this dual-view approach, you can easily adapt the technique for a dedicated first-person shooter (FPS) game as well. Next we need to integrate Coherent Gameface into our game. We can do that by following the [getting started guide ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/)from our documentation. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/curved-hud/#adding-the-cohtml-plane-to-our-character] ## How to create a Fish-eyed using a curved plane: Adding the CoHTML Plane to our character Next, we’ll add the CoHTML Plane to our character. Open the content drawer and navigate to `Plugins > Gameface Content > CohtmlPlane`: Since creating an instance of the Blueprint Class within another Blueprint Class isn’t possible, we’ll simply duplicate the CohtmlPlane class. And then drag and drop it into our ThirdPersonCharacter Blueprint: Ensure that it is added as a child of the CameraBoom component, so it follows the camera’s movements: When we run the game, we should see our plane positioned in front of the camera. Depending on how accurately we’ve placed it within the Blueprint Class, we might need to make some adjustments to achieve the desired positioning. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/curved-hud/#changing-the-plane-mesh] ## How to create a Fish-eyed using a curved plane: Changing the plane mesh To achieve the fish-eye effect, we need to modify the mesh of our CohtmlPlane to be a curved plane. We’ll create a new plane in Blender and use modifiers to bend it. You can follow this [tutorial ](https://www.youtube.com/watch?v=KHVtvI7M9mQ)for detailed instructions. In our case, we’ll bend the plane along both the X and Z axes to achieve the desired curvature. Once the modifications are complete, export the plane as an FBX file. Then, import it into your content drawer by dragging and dropping the file. Next, double-click on the duplicated Blueprint Class for the plane. Inside, select the `StaticMesh` component. In the settings panel on the right, locate the Static Mesh option and select the newly imported curved mesh. Now, when we open the UI in the game, we should see it displayed with a curved effect. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/curved-hud/#in-conclusion] ## How to create a Fish-eyed using a curved plane: In conclusion By applying the changes in this guide, you can create a fish-eye HUD that enhances your game’s visual style. Experimenting with different intensities and UI placements will help you strike the right balance between aesthetics and readability. Now that you understand the fundamentals, try integrating this effect into your own projects! ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/custom-cursor/] ## Custom CSS Cursor (1/2) ## Custom CSS Cursor ui tutorials 3/28/2024 Tony Gruev 1. Mouse Movement Using attributeStyleMap 2. Limitations and Peculiarities 1. Remove the body margin 2. Scrollable Page 3. Frame rate dependency 3. OS-controller Cursor (Recommended) A custom cursor is a must-have for every game, it brings forward the vibe and atmosphere of the game. We will use only CSS and JavaScript to hide the default cursor and move a custom one with an image. **It is recommended** to use the OS-controller Cursor . The [CSS Typed Object Model ](https://docs.coherent-labs.com/cpp-gameface/content_development/csstypedobjectmodel/#using-the-css-typed-object-model)will be utilized for a better performance. A sample showing changing the mouse cursor image and increasing its size can be found in the Gameface package in folder **Samples\uiresources\UITutorials\CustomCSSCursor**. Fist of all we hide the default cursor with: ```css html { cursor: none; } ``` Now the element for that cursor is: ```html
    ``` The styles for the cursor: ```css .cursor { position: absolute; top: 0; left: 0; width: 55px; height: 55px; background-image: url('./assets/mouse1.svg'); background-position: 50% 0; background-repeat: no-repeat; /* pass events throught the cursor element */ pointer-events: none; /* should always be on top of every element but can be omitted if top level elements don't have z-index and the cursor element is at the end of the */ z-index: 1; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/custom-cursor/] ## Custom CSS Cursor (2/2) Although the default cursor may not be visible, it remains present. Therefore, when we click on the document, the `.cursor` element will capture the pointer events. To prevent this and allow the event to propagate to the element beneath the `.cursor` element, we must disable its pointer-events using `pointer-events: none`. **Important:** Make sure the `.cursor` element has the highest `z-index` value over all the elements on the page. In case you don’t change the `z-index` - placing the `.cursor` element at the end of the `` without `z-index` will suffice. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/custom-cursor/#mouse-movement-using-attributestylemap] ## Custom CSS Cursor: Mouse Movement Using attributeStyleMap And finally the JavaScript we need: ```js const cursor = document.getElementById('cursor'); // Cache the attributeStyleMap for the cursor element const cursorStyleMap = cursor.attributeStyleMap; // Save the new CSSTransformValue to reuse it in cursorStyleMap.set() const mouseTransform = new CSSTransformValue([new CSSTranslate(CSS.px(0), CSS.px(0))]); // Save the properties from CSSTransformValue that are going to be changed const mouseTransformTranslateX = mouseTransform[0].x; const mouseTransformTranslateY = mouseTransform[0].y; document.addEventListener('mousemove', (e) => { const {x, y} = e; mouseTransformTranslateX.value = x; mouseTransformTranslateY.value = y; cursorStyleMap.set('transform', mouseTransform); }); ``` The cursor icon can be changed easily also. For example, by entering another element: ```js changeBox.addEventListener('mouseover', () => { cursor.classList.toggle('cursor2'); }); ``` And this requires only for the background image to be changed: ```css .cursor2 { background-image: url('./assets/mouse2.svg'); } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/custom-cursor/#limitations-and-peculiarities] ## Custom CSS Cursor: Limitations and Peculiarities There are some particularities that need to be taken into account. #### Remove the body margin Disabling the `margin` on the body prevents the cursor element from being offset from the OS cursor position. ```css body { margin: 0; } ``` #### Scrollable Page In case the page is scrollable, you will need to take that into account in the `mousemove` EventListener: ```js // ... mouseTransformTranslateX.value = x + window.scrollX; mouseTransformTranslateY.value = y + window.scrollY; // ... ``` Also the cursor element is updated only on `mousemove` and there is a need to watch for scrolling with the `scroll` event: ```js let cacheMousePositions = {x: 0, y: 0}; document.addEventListener('scroll', (e) => { mouseTransformTranslateX.value = cacheMousePositions.x + window.scrollX; mouseTransformTranslateY.value = cacheMousePositions.y + window.scrollY; cursorStyleMap.set('transform', mouseTransform); }); ``` and the coordinates can be saved in the `mousemove` EventListener : ```js cacheMousePositions = {x, y}; ``` #### Frame rate dependency Since this front-end approach is relying on how fast the application is running, there will be a delay after moving the mouse and when the cursor element catches on. The lower the frame rate, the bigger the delay. For information how to use the OS-controlled cursor, check the section below. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/custom-cursor/#os-controller-cursor-recommended] ## Custom CSS Cursor: OS-controller Cursor (Recommended) It is recommended to use the OS-controlled cursor - read the [Cursor control ](https://docs.coherent-labs.com/cpp-gameface/integration/optional_features/inputhandlingcpp_native/#CursorControl)in the Gameface documentation. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/] ## Creating a damage indicator ## Creating a damage indicator ui tutorials 12/5/2024 Mihail Todorov 1. Getting started 1. Setting up our HTML 2. Styling the indicator 3. Adding the data-bindings 2. Adding to a game 1. Setting up the project 2. Spawning the damage origin 3. Calculating the angle 4. Passing our angle to the game 5. Calling our custom event again 6. Updating the angle during the game 3. In conclusion In any action-packed game, conveying clear and immediate feedback to players is crucial for a satisfying experience. A damage indicator UI can significantly enhance gameplay by visually communicating when and where damage occurs. This article dives into how you can design and implement a responsive and immersive damage indicator UI, providing players with vital real-time feedback during intense gameplay moments. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/#getting-started] ## Creating a damage indicator: Getting started (1/3) We’ll start by creating our UI separately. To do that we’ll need only a single HTML page and the `cohtml.js` file. As many damage indicators show from where the damage comes from in a sort of a triangle that goes from the center to the edge and follows the origin of the damage to notify the player. To recreate this we’ll use the [conic-gradient ](https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/conic-gradient). #### Setting up our HTML For this case we’ll be using data-bindings to show the indicators on the screen and rotate them. This is why we’ll need to create for each indicator two elements, one which will be the wrapper and another where the indicator will be. This is because data-bindings in Gameface are not always evaluated in the same order. If we use a structural data-binding, like in our case `data-bind-for` to loop the elements, we need to make sure that there is a wrapper for the data-binding. ```html
    ``` #### Styling the indicator In the `style` tag we’ll add the following CSS: ```css body { width: 100vw; height: 100vh; margin: 0; } .damage-overlay { --angle: 90deg; position: absolute; width: 100vw; height: 100vh; background-image: conic-gradient( from var(--angle) at 50% 50%, red 1%, transparent 2%, transparent 99%, red 100% ); } ``` This will put the indicators on top of each other so they can be stacked. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/#getting-started] ## Creating a damage indicator: Getting started (2/3) Something to note is that we have set in the `.damage-overlay` element a variable called `angle`. This variable will allow us to change the angle of the indicator instead of having to reset the whole background image. #### Adding the data-bindings For this case we’ll add a `Damage` model that will contain all of our indicators. Since we are currently working without a game, we’ll need to mock that data. So in our JS we’ll do: ```js engine.whenReady.then(() => { engine.createJSModel('Damage', { damages: [ { angle: '83deg', time: 1, }, ], }); engine.synchronizeModels(); }); ``` Where we’ll create our `Damage` model and add the `damages` property which will have all of our indicators. Each one will have the angle and the time that it will be on the screen. In our case this time will also relate to the opacity of the element. With that data, we can add the data-bindings to our html. ```html
    ``` You may notice that there is no binding for the angle and the reason is that there is no built in data-binding for changing variables. This is why we’ll create our own custom data-binding. We’ll declare a class that will be our handler for the data-bindings and we’ll use the `init` and `update` methods to change the variable. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/#getting-started] ## Creating a damage indicator: Getting started (3/3) ```js class AngleHandler { init(element, value) { element.style.setProperty('--angle', value); } update(element, value) { element.style.setProperty('--angle', value); } } ``` Then we need to register the new binding attribute: ```js engine.whenReady.then(() => { engine.createJSModel('Damage', { damages: [ { angle: '83deg', time: -1, }, ], }); engine.registerBindingAttribute('angle', AngleHandler); engine.synchronizeModels(); }); ``` And we add the new data-binding to the element: ```diff
    ``` Now by changing the angle in our model, we can change the angle of our indicator. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/#adding-to-a-game] ## Creating a damage indicator: Adding to a game (1/3) Although this is all there is to adding a damage indicator that rotates with the damage origin, it still doesn’t have any actual data. This is why we’ll add it to Unreal’s ThirdPerson sample. #### Setting up the project Before we start adding it, we need to set up our project in Unreal Engine. We’ll use the [getting started guide ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/)from our documentation to install the Gameface plugin and integrate it into an existing project or use the sample project created by the installer. #### Spawning the damage origin The first thing in our game that we need to do is to set a random point in our world that will be where the damage occurred and our damage indicator will point to it. To do that we’ll add a new `NavMeshBoundsVolume` to our map and place it over the ground. This will allow us to call the blueprint node - `GetRandomLocationInNavigatableRadius` We’ll set the location to be in a radius of `200` around our player. We’ll also call this in an event listener so that we can call it at a random interval later. #### Calculating the angle Now that we have the location of our damage origin, we need to calculate the angle between the player and that origin. To do that we’ll make a new function called `CalculateAngle`. In this function we are doing the following: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/#adding-to-a-game] ## Creating a damage indicator: Adding to a game (2/3) 1. We get the player mesh location in the world 2. We get the damage origin location that is passed to the function 3. We convert the 3D coordinates of both into 2D screen coordinates 4. We then use the `FindLookAtRotation` function to calculate the angle between both 5. Finally the angle that we get we offset by 90 degrees as the coordinate systems between Unreal and the web are different and we add the necessary suffix in order to pass it to our UI The reason that we convert the 3D to 2D coordinates is because this allows us to easily account for things like camera and character movement. This approach hover comes with the downside that if you are far away from the origin it will be offscreen and it’s coordinate will not be properly translated. #### Passing our angle to the game Next to pass our angle we’ll create two structs - one will be our model `Damage` which will have a key `damages` that will be an array of our second struct - the `indicator` itself. The `indicator` will have the `angle`, `time` and also the original damage origin so that we are able to update the angle during the game. We’ll set the members of the `indicator` struct and then add it to an `indicator array`. After that we can add to our `Damage` struct the array and create a model from it. #### Calling our custom event again Finally we’ll set it so that we can call our custom event over and over again at a random interval. #### Updating the angle during the game --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/#adding-to-a-game] ## Creating a damage indicator: Adding to a game (3/3) The last thing we need to do is to update the angle of our damage indicator when the game runs so that it will rotate when we move the player and camera. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/damage-indicator/#in-conclusion] ## Creating a damage indicator: In conclusion By implementing an intuitive damage indicator UI, you’re not only improving gameplay feedback but also creating a more engaging experience for your players. Experiment with animations, colors, and positioning to ensure your UI fits seamlessly into your game’s style and mechanics. With these techniques, your game will stand out for its polished and player-focused design. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/] ## Creating a dialogue tree for your game ## Creating a dialogue tree for your game ui tutorials 10/1/2024 Mihail Todorov 1. Where to find the working example 2. Creating our dialogue tree 3. Setting up our dialogue UI 4. Selecting an option 1. Creating the typing effect 2. Creating the response options 3. Adding interactions 4. Tying everything together 5. In conclusion Creating a dialogue tree is essential for immersive storytelling in games, allowing for dynamic conversations between players and NPCs. Coherent Gameface, with its powerful UI system, offers a robust way to build and display these dialogue systems. In this tutorial, we’ll walk through how to create a dialogue tree from scratch using Gameface, helping you bring more interactive experiences into your game. #### Where to find the working example You can find the whole project source in the `${Gameface package}/Samples/uiresources/UITutorials/DialogueTree` folder. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#creating-our-dialogue-tree] ## Creating a dialogue tree for your game: Creating our dialogue tree (1/2) The first thing we need to do is create our dialogue tree. For this example we’ll be creating a dialogue tree that has 2 to 3 options per dialogue and will be at least 5 levels deep. Once we have that we need to present it in a format that will benefit us the most. This is why for this particular example we’ll make it into a JavaScript object in the following format ```js { text: "", responses: [ { text: "", dialogueNumber: 0, } ] } ``` Where `text` is the guild master question, and responses are the possible choices that the player would have. In the responses `dialogueNumber` refers to the guild master question that will be shown when the response is chosen and it’s index in the array. For this example we’ve added the dialogue tree as JavaScript array as we are mocking the interactions, but in a game it should come from the backend/game. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#creating-our-dialogue-tree] ## Creating a dialogue tree for your game: Creating our dialogue tree (2/2) ```js const dialogueTree = [ { text: "Ah, welcome! I hear you've come seeking work. There's a mission available, but it's not for the faint of heart. What do you say? Interested?", responses: [ { text: "Yes, I'm ready for anything.", dialogueNumber: 1, }, { text: "Tell me more before I decide.", dialogueNumber: 2, }, { text: "I'm not sure. What's the reward?", dialogueNumber: 3, } ] }, { text: "Good to hear! There's a band of marauders causing trouble near the northern pass. We need someone to deal with them. Do you accept?", responses: [ { text: "I'll take care of it.", dialogueNumber: 4, }, { text: "Is there any backup for this mission?", dialogueNumber: 5, } ] }, { text: "The mission involves taking down a notorious bandit leader. They've terrorized nearby villages for weeks. You'll need to be clever as well as strong. What do you think?", responses: [ { text: "I'll do it. The villages need help.", dialogueNumber: 6, }, { text: "This sounds dangerous. How many people are we talking about?", dialogueNumber: 7, } ] }, { text: "The reward? Well, aside from the gratitude of the villages, there's gold and a rare item—a relic with great power.", responses: [ { text: "I'm in. Tell me what needs to be done.", dialogueNumber: 8, }, { text: "A relic? What kind of power are we talking about?", dialogueNumber: 9, } ] }, { text: "Excellent. You leave immediately. I'll mark the location on your map. Be careful out there.", responses: [ { text: "Understood. I'm heading out now.", dialogueNumber: null, }, { text: "Any advice before I go?", dialogueNumber: 10, } ] }, { text: "We're sending only you. The Guild is stretched thin right now. Do you still want to proceed?", responses: [ { text: "Yes, I'll manage.", dialogueNumber: null, }, { text: "No, I need support.", dialogueNumber: null, } ] }, { text: "Good. You'll be a hero to these people.", responses: [ { text: "I'll make sure of it.", dialogueNumber: null, } ] }, { text: "The leader has a handful of loyal fighters, but their numbers are small. A direct fight might not be wise.", responses: [ { text: "I'll take them by surprise, then.", dialogueNumber: null, }, { text: "What if I negotiate with them?", dialogueNumber: 11, } ] }, { text: "Head to the northern pass and find the marauders. The relic is rumored to be in their possession.", responses: [ { text: "I'll find it and take them down.", dialogueNumber: null, }, { text: "Is there a safe way to retrieve the relic without fighting?", dialogueNumber: 12, } ] }, { text: "It's an ancient charm said to grant enhanced strength in battle. Many would pay a high price for it.", responses: [ { text: "That's good enough for me. I'll take the mission.", dialogueNumber: 8, }, { text: "That sounds too dangerous for me. I'll pass.", dialogueNumber: null, } ] }, { text: "Negotiating with bandits? You'd be risking everything. But if that's what you believe is right, I won't stop you.", responses: [ { text: "I'll find a way to end this peacefully.", dialogueNumber: null, }, { text: "On second thought, I'll go with the ambush.", dialogueNumber: null, } ] }, { text: "Perhaps, if you're stealthy enough. But I doubt they'll let you walk out with it once they see you.", responses: [ { text: "I'll risk it. I'm good at staying unseen.", dialogueNumber: null, }, { text: "I'll think of another approach.", dialogueNumber: null, } ] } ]; ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#setting-up-our-dialogue-ui] ## Creating a dialogue tree for your game: Setting up our dialogue UI (1/3) Before we make the logic for the dialogues we first need to set up the visual part. That would include creating our HTML and styling using the CSS. In our HTML we have two major containers - the `.npc-dialogue-container` and the `.player-options-container` which will be inside the **npc-dialogue-container** ```html
    Guild Master: "Ah, welcome! I hear you've come seeking work. There's a mission available, but it's not for the faint of heart. What do you say? Interested?"

    Yes, I'm ready for anything.

    Tell me more before I decide.

    I'm not sure. What's the reward?

    Press Enter to select the dialogue option
    ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#setting-up-our-dialogue-ui] ## Creating a dialogue tree for your game: Setting up our dialogue UI (2/3) Here you can see in this HTML snippet, that we are using the first question and responses from the dialogue tree array. The reason is that we want it to be availabe when you load the sample, but in a real use-case scenario you can add the data using JavaScript. Something else that we need to note here is that we add to the `player-options` an id that will be the `dialogueNumber` from the responses. Once that is done we’ll simply style or UI by adding the following `style.css` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#setting-up-our-dialogue-ui] ## Creating a dialogue tree for your game: Setting up our dialogue UI (3/3) ```css @font-face { font-family: "IM FELL Double Pica SC"; src: url(../assets/im-fell-double-pica.sc.ttf); } body { margin: 0; padding: 0; font-family: "IM FELL Double Pica SC"; width: 100vw; height: 100vh; color: white; font-size: 2.4vh; background-image: url(../assets/guild-master.jpg); background-repeat: no-repeat; background-size: cover; background-position: center; } .npc-dialogue-container { position: absolute; bottom: 3%; width: 100vw; display: flex; align-items: center; justify-content: center; } .npc-dialogue { width: 80%; height: 13vh; display: flex; align-items: center; background-color: rgba(0, 0, 0, 0.7); padding: 0 3vh; border-image-slice: 27; border-image-width: 40px; border-image-outset: 0; border-image-repeat: stretch; border-image-source: url(../assets/dialogue-border.png); border-radius: 10px; } .guild-master { width: 20%; color: #eecd9c; } .guild-master-text { width: 80%; } .player-options-container { position: absolute; bottom: 120%; right: 7%; } .player-option { border-image-slice: 15; border-image-width: 40px; border-image-outset: 0; border-image-repeat: stretch; border-image-source: url(../assets/dialogue-border.png); padding: 2vh; width: 40vh; display: flex; align-items: center; justify-content: center; background-image: linear-gradient( to right, transparent, black 50%, transparent ); } .player-option:focus { background-image: linear-gradient( to right, transparent, #ac864d 50%, transparent ); } .player-option:hover { background-image: linear-gradient( to right, transparent, #ac864d 50%, transparent ); } .help-text { position: absolute; top: 15%; left: 50%; transform: translate(-50%, -50%); background-color: black; padding: 1vh; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#selecting-an-option] ## Creating a dialogue tree for your game: Selecting an option (1/5) #### Creating the typing effect In many games where you have dialogues the text appears as if it was typed on screen. To mimic this we’ll create a function called `writeText` and add the following code ```js const guildMaster = document.querySelector(".guild-master-text"); let interval, skipText = false; function writeText(dialogue) { return new Promise((resolve) => { let index = 0; interval = setInterval(() => { if (index === dialogue.text.length || skipText) { skipText = false; resolve(dialogue); clearInterval(interval); interval = null; return; } guildMaster.textContent += dialogue.text[index]; index++; }, 25); }); } ``` Here we return a `Promise` so that when the text finishes typing out, we can show the options for a response. We then set an interval and on each iteration we add a letter to the `guildMaster` element text content. Once all of the letters are typed out we clear the interval and resolve the promise. We’ll also use a flag `skipText`, which will stop the interval and resolve the promise. This will allow us later to skip the text typing out if we want. #### Creating the response options To create the response options we’ll first set a template ```js function createDialogueOptionTemplate(text, id) { return `

    ${text}

    `; } ``` where we set the `id` and the `text`. Then we create a function to add the options --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#selecting-an-option] ## Creating a dialogue tree for your game: Selecting an option (2/5) ```js const options = document.querySelector(".player-options-container"); function addOptions(dialogue) { clearInterval(interval); interval = null; guildMaster.textContent = dialogue.text; options.innerHTML = dialogue.responses.reduce( (acc, response, index) => { acc += createDialogueOptionTemplate(response.text, index); return acc; }, "" ); options.firstChild.focus(); //We focus on the first option so it's easier to interact later using the keyboard } ``` And finally we set the guild master dialogue along with the options ```js function setDialogue(dialogue) { guildMaster.textContent = ""; //Clear the previous text options.textContent = ""; //Clear the options as well writeText(dialogue.text).then(addOptions); } ``` #### Adding interactions For this example we’ll be using both the keyboard and the mouse to select a response. This is why we’ll add two event listeners - for `click` and for `keydown` ```js document.addEventListener("click", () => {}); document.addEventListener("keydown", () => {}); ``` In our `click` event we need to check if the item that we are clicking is a response option and if the text is being typed out we want to skip it. First we’ll create a function that handles the option selection. ```js function selectOption(element) { const id = element.id; engine.trigger("selectDialogue", id); } ``` Where we get the id that we’ve set to correspond to the correct dialogue index and trigger an event in our game with it. Now in the `click` event handler we do the following: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#selecting-an-option] ## Creating a dialogue tree for your game: Selecting an option (3/5) ```js document.addEventListener("click", ({ target }) => { if (target.closest(".player-options-container")) { selectOption(target); return; } if (interval) { skipText = true; return; } }); ``` We check if the clicked element is an option and then run the function we’ve created. And we also check if the interval is set. If it is we change the `skipText` flag to true and it will resolve the promise in the `writeText` function. Now we can do the same in the `keydown` handler ```js document.addEventListener("keydown", ({ keyCode }) => { if (keyCode === 13) { // ENTER key if (document.activeElement.closest(".player-options-container")) { selectOption(document.activeElement); return; } if (interval) { skipText = true; return; } } }); ``` We check if the user pressed enter, then we check if the current focused item is from the options and we select it. Since we don’t have the ability to choose which option, we’ll also add the following logic to our `keydown` handler: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#selecting-an-option] ## Creating a dialogue tree for your game: Selecting an option (4/5) ```js document.addEventListener("keydown", ({ keyCode }) => { if (keyCode === 13) { if (document.activeElement.closest(".player-options-container")) { selectOption(document.activeElement); return; } if (interval) { skipText = true; return; } } if (keyCode === 38) { //Arrow key down const nextSibling = document.activeElement.previousElementSibling; if (nextSibling) nextSibling.focus(); else options.firstChild.focus(); } if (keyCode === 40) { //Arrow key up const prevSibling = document.activeElement.nextElementSibling; if (prevSibling) prevSibling.focus(); else options.lastChild.focus(); } }); ``` Here we check if the arrow up or down keys are pressed and if they are we focus on the next or previous sibling, depending on the key. If there is no sibling, meaning that the element is the first or last we just focus the last or first element so we can loop it around. #### Tying everything together We’ve added all of our logic, but even if we try to select an option nothing will happen as we haven’t “hooked it up to the game” yet. In this scenario we would listen for the `"selectDialogue"` event on our backend and then trigger an event from the game that will send us the correct text. Since we don’t have a game we’ll mock that by listening for said event and getting the data from the `dialogueTree` array like so: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#selecting-an-option] ## Creating a dialogue tree for your game: Selecting an option (5/5) ```js engine.whenReady.then(() => { engine.on("selectDialogue", (id) => { let index = dialogueTree[currentDialogueIndex].responses[id].dialogueNumber; if (!index) index = 0; engine.trigger("changeDialogue", dialogueTree[index], index); }); engine.on("changeDialogue", (dialogue, index) => { currentDialogueIndex = index; setDialogue(dialogue); }); }); ``` We wait for the engine object to be available, then we get the text from the `dialogueTree` when the event is triggered, here we need to check if the `dialogueNumber` is `null` and if it is we go back to the first text. And finally we trigger another event that will be listening on the frontend to change the text. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/dialogue-tree/#in-conclusion] ## Creating a dialogue tree for your game: In conclusion By following this guide, you’ve now learned how to create a functional dialogue tree using Coherent Gameface. With this system in place, your games can have branching conversations that enhance player immersion and choice. As you get more comfortable with Gameface, you can expand and customize your dialogue trees to meet the narrative needs of your game. Stay creative and keep exploring the possibilities Gameface brings to UI design! ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/] ## How to create different types of bars in Gameface ## How to create different types of bars in Gameface ui tutorials 2/6/2025 Mihail Todorov 1. What kinds of bars are we going to create in this tutorial 2. Radial Bar 3. Segmented Bar 4. Equalizer bar 5. Bidirectional bar 6. In conclusion Bars are a fundamental part of any game UI, used to represent health, mana, stamina, loading progress, and more. But not all bars are created equal—some are segmented, others deplete radially, and some even animate bidirectionally. In this guide, we’ll cover different bar types, their use cases, and how to implement them effectively in your game. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#what-kinds-of-bars-are-we-going-to-create-in-this-tutorial] ## How to create different types of bars in Gameface: What kinds of bars are we going to create in this tutorial We are going to create 4 types of bars: A radial bar: A segmented bar: An equalizer bar: A bar that expands in both directions: These bars offer unique visual styles compared to the traditional horizontal or vertical bars and can be easily created using Coherent Gameface. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#radial-bar] ## How to create different types of bars in Gameface: Radial Bar (1/3) A radial bar is a simple yet effective way to represent progress in a circular manner. Here’s how you can create one using Coherent Gameface: First, create the HTML structure for the radial bar. You will need a container and an SVG element to draw the circular path. We will use `stroke-dashoffset` and `stroke-dasharray` to create the filling effect. Since Gameface supports these properties only on `path` elements, we need to use a `path` instead of a `circle`. ```html ``` We also added two paths: one will be the fill, and the other will serve as the container for the fill. And to center the icon, we’ll wrap the entire structure in a container and position the image absolutely on top. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#radial-bar] ## How to create different types of bars in Gameface: Radial Bar (2/3) ```html
    ``` Now to style our bar: ```css .circle-bar { width: 70%; /*This way it will be depended on the parent container, if you want to use it separately, you need to input your own width and height*/ height: 30%; position: relative; } .circle-bar-svg { width: 100%; height: 100%; } .circle-bar-fill { stroke-dashoffset: 250; stroke-dasharray: 250; transform: rotate(90deg); /*We rotate the circle since the stroke-dashoffset doesn't start from our desired location*/ transform-origin: center; } .circle-bar-icon { position: absolute; background-position-x: 50%; background-position-y: 50%; background-size: 53% 30%; width: 100%; height: 100%; background-repeat: no-repeat no-repeat; } ``` To complete our radial bar, we need to adjust the stroke-dasharray and stroke-dashoffset values. - When the stroke-dashoffset is set to 250, the bar appears empty. - When the stroke-dashoffset is set to 0, the bar is fully filled. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#radial-bar] ## How to create different types of bars in Gameface: Radial Bar (3/3) So, when we connect this to the game, we need to remember: - 250 means the bar is 0% filled (empty). - 0 means the bar is 100% filled. To make it functional, we need to connect it to our game. There are two ways to achieve this: using data-binding or using events. **Using data-binding** If we have a model registered in our game, all we have to do is to add the following to our path element: ```diff ``` **Using events** Using events requires adding some extra lines of code to our JavaScript: ```js engine.on('updateRadialBar', (value) => { const radialBar = document.querySelector('.circle-bar-fill'); radialBar.style.strokeDashOffset = value; }); ``` The final result will be: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#segmented-bar] ## How to create different types of bars in Gameface: Segmented Bar (1/4) A segmented bar is a type of progress bar that is divided into multiple segments or sections, each representing a distinct part of the overall progress. Use Cases: - Multi-step Processes: Ideal for visualizing progress in multi-step forms or workflows, where each segment represents a step. - Task Completion: Useful in applications where multiple tasks need to be completed, with each segment representing a task. - Health and Status Indicators: Common in games and applications to show different levels of health, battery, or other status indicators. - Data Visualization: Can be used to represent different categories or parts of data in a visually appealing way. We’ll start by adding our HTML to the page for the bar: ```html
    ``` What we do differently here is that instead of containing the fill within the frame, we’ll wrap a larger frame around the fill and skew the fill. To do this we’ll add the following style: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#segmented-bar] ## How to create different types of bars in Gameface: Segmented Bar (2/4) ```css .bar-container { width: 36vh; height: 5vh; } .bar-container-frame { width: 100%; height: 100%; background-image: url(./bar-container.png); background-size: 100% 100%; background-repeat: no-repeat; position: absolute; } .bar-container-fill { width: 76%; /*As we skew the fill and try to fit it in a frame, the width is not going to always be 100%*/ height: 61%; margin-left: 6.5vh; background-image: linear-gradient(to right, transparent 20%, #e7b842 0%); /*This actually creates our segmented look*/ background-size: 2.736vh 100%; transform: skewX(48deg); } ``` Once the segmented bar is visually complete, we have two options to control its appearance: 1. **Changing the Width**: This method involves adjusting the width of the fill to represent different progress levels. For example, you might set the width to 76% for a full bar and 69% for one segment less. This approach requires precise adjustments for each segment. 2. **Using CSS Animations**: This method involves creating a CSS animation to control the bar’s appearance. You can then manipulate the animation using either the Web Animations API or by setting a negative animation delay to achieve the desired effect. Using CSS animations is easier so we’ll go with that approach. We’ll create the animation: ```css @keyframes bar-anim { from { width: 0%; } to { width: 76%; } } ``` and add it to our bar: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#segmented-bar] ## How to create different types of bars in Gameface: Segmented Bar (3/4) ```css .bar-container-fill { width: 76%; height: 61%; margin-left: 6.5vh; background-image: linear-gradient(to right, transparent 20%, #e7b842 0%); background-size: 2.736vh 100%; transform: skewX(48deg); animation: bar-anim 1s steps(10) linear paused; } ``` Notice how we use `steps` in the animation. This allows Coherent Gameface to automatically split the animation into segments, eliminating the need for manual adjustments. To connect it to our game we again can use either `data-binding` or `events`. This time however we’ll demonstrate how to use data-binding with the `animation-delay` and the events with the WAAPI. **Using data-binding** If we have a model registered in our game, we can bind the animation delay to our model: ```html
    ``` Negative animation delay can be used to control the starting point of an animation. By setting a negative delay, you effectively start the animation partway through its cycle. This is useful for segmented bars where you want to show progress at different stages without restarting the animation. For an animation with a 1-second duration and 10 steps like this one, each step represents 0.1 seconds (100ms). By using negative delays, you can control which step the animation starts from. For example: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#segmented-bar] ## How to create different types of bars in Gameface: Segmented Bar (4/4) ```css animation-delay: -0.1s /*starts the animation at the first step (10% progress).*/ animation-delay: -0.2s /*starts the animation at the second step (20% progress).*/ animation-delay: -0.3s /*starts the animation at the third step (30% progress).*/ ``` Since also our `animation-state` is set to `paused` it will just go to the correct animation frame. In this case our model should have values from 0 to 1 to represent the steps of the segmented bar. **Using Events** Just like in our radial bar example, we need to listen for an event, but this time we’ll use the WAAPI (Web Animations API) to control the animation. ```js engine.on('updateSegmentedBar', (value) => { const segmentedBar = document.querySelector('.bar-container-fill'); const animation = segmentedBar.getAnimations()[0]; if (animation) { //We need to make sure there is an animation so it doesn't throw an error animation.currentTime = value * 1000; // value should be between 0 and 1 } }); ``` The final result will be: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#equalizer-bar] ## How to create different types of bars in Gameface: Equalizer bar (1/2) The equalizer bar is a type of segmented bar that features segments in varying colors. This design is particularly useful for providing visual cues when certain values are reached, similar to how audio level equalizer bars indicate different sound intensities. There are two ways to create an equalizer bar: using multiple elements for each segment or using a single image. Using multiple elements gives you more control over each segment but can impact performance, especially if you have many bars. Using a single image is more efficient and simpler to implement. We’ll start by adding our HTML: ```html
    ``` and styling it: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#equalizer-bar] ## How to create different types of bars in Gameface: Equalizer bar (2/2) ```css .sound-container { width: 20vh; height: 22vh; position: absolute; top: 47%; transform: translateY(-50%); right: 8%; opacity: 0.7; } .sound-levels { height: 40%; width: 100%; display: flex; } .sound-bar { height: 100%; border: 0.1vh solid #9bf2fa; width: 12.5%; } .sound-bar-fill { width: 100%; height: 100%; background-image: url(./sound-bar.png); background-size: 100% 100%; mask-image: linear-gradient(to bottom, white, white); mask-size: 100% 0%; mask-position: bottom center; mask-repeat: no-repeat; animation: sound 1s steps(17) linear; } ``` Here, we create a mask using a gradient and adjust its size to achieve the desired effect: ```css @keyframes sound { from { mask-size: 100% 0%; } to { mask-size: 100% 100%; } } ``` Since we are utilizing an animation, connecting it to our game follows the same approach as with the segmented bar. The final result will be: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#bidirectional-bar] ## How to create different types of bars in Gameface: Bidirectional bar A bidirectional bar is a unique type of progress bar that expands in both directions from a central point. Creating this bar follows the same principles as a standard progress bar, with a slight modification to achieve the bidirectional effect. The HTML follows the standard way of using a container and fill: ```html
    ``` ```css .visualizer { height: 7vh; border: 0.3vh solid white; position: absolute; bottom: 28%; right: 5.9%; display: flex; align-items: center; padding: 0.4vh; opacity: 0.7; } .track { width: 1vh; height: 0%; background-color: white; margin: 0 0.2vh; } ``` The key to achieving this effect lies in using the flexbox layout with `display: flex` and `align-items: center`. This setup ensures that when the bar’s width changes, it expands symmetrically from the center rather than from one end. Connecting it to the game is straightforward. You can either use `data-bind-style-width` if you have a model, or handle it with events by adjusting the width, similar to the approach used in the radial bar. The final result will be: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/different-bars/#in-conclusion] ## How to create different types of bars in Gameface: In conclusion From simple linear bars to complex radial and segmented designs, implementing the right type of bar can enhance both functionality and visual appeal. By understanding the mechanics behind different bar styles, you can tailor your UI elements to fit your game’s needs. Now, go ahead and experiment with different designs to find the best fit! ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide ui tutorials 8/28/2025 Martin Bozhilov 1. What’s new in the Menu 2. Component Customization 3. Slider 1. Step 1 — Creating the wrapper 2. Step 2 — Styling 3. Step 3 — Making it functional 4. Step 4 — Making it reusable 4. Segment 1. Using TypeScript for Autocomplete In the latest update [**GameFace UI** ](https://gameface-ui.coherent-labs.com/)ships a refreshed Menu UI that highlights our newest components out of the box. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#whats-new-in-the-menu] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: What’s new in the Menu (1/3) The new UI for the menu view now showcases the following components: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#whats-new-in-the-menu] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: What’s new in the Menu (2/3) - [Scroll ](https://gameface-ui.coherent-labs.com/components/layout/scroll)- The scroll component is great for display long menu options lists while preserving a defined structured, without overflow. - [Tabs ](https://gameface-ui.coherent-labs.com/components/layout/tabs/)- The tabs component is perfect for organizing content into separate views, making it easy for users to navigate between different sections of the menu. - [Modal ](https://gameface-ui.coherent-labs.com/components/basic/modal/)- The modal component is used for displaying important information or actions that require user attention, such as confirming changes before navigating away from a tab. - [Segment ](https://gameface-ui.coherent-labs.com/components/basic/segment/)- The segment component is ideal for selecting between multiple options in a compact and visually appealing way, such as choosing keybind presets. - [Dropdown ](https://gameface-ui.coherent-labs.com/components/basic/dropdown/)- The dropdown component is useful for selecting from a list of options without taking up too much space in the UI, such as selecting resolution, graphics quality or a language. - [Stepper ](https://gameface-ui.coherent-labs.com/components/basic/stepper/)- The stepper component is great for incrementing or decrementing values in a controlled manner, such as adjusting the difficulty level of a game. - [ToggleButton ](https://gameface-ui.coherent-labs.com/components/basic/toggle-button/)- The toggle button component is perfect for enabling or disabling settings with a simple switch, such as turning on/off fullscreen mode or VSync. - [Slider ](https://gameface-ui.coherent-labs.com/components/basic/slider/)- The slider component is ideal for selecting a value within a range, such as adjusting mouse sensitivity or field of view. - [TextSlider ](https://gameface-ui.coherent-labs.com/components/basic/text-slider/)- The text slider component is useful for selecting from a list of predefined options in a visually appealing way, in our case we used it for subtitle size selection. - [NumberInput ](https://gameface-ui.coherent-labs.com/components/basic/number-input/)- The number input component is great for entering numerical values directly, such as setting a custom frame rate limit. - [Checkbox ](https://gameface-ui.coherent-labs.com/components/basic/checkbox/)- The checkbox component is perfect for toggling options such as enabling/disabling various accessibility features. - [List ](https://gameface-ui.coherent-labs.com/components/layout/list/)- The list component is useful for displaying a list of items in a structured manner. It has a wide veriety of use cases, in our case we used it to display additional information about the settings and on the end credits. - [ColorPicker ](https://gameface-ui.coherent-labs.com/components/complex/color-picker/)- The color picker component is ideal for selecting colors in a user-friendly way, such as customizing the crosshair color. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#whats-new-in-the-menu] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: What’s new in the Menu (3/3) The complete Menu UI is located at `src/views/menu/Menu.tsx` in your Gameface UI project. To preview it, run `npm run dev` and open the Player at `localhost:3000/menu`. All components in the menu have been styled to match the new UI. You’ll find these customized components in `src/custom-components/Menu/`. Next, let’s explore how some of these components were tailored and how their features help create an interactive menu experience! --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#component-customization] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Component Customization Since most components will be reused across the UI, it’s better to wrap them into custom components. This allows you to centralize styling, define common behavior, and keep consistency. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (1/10) Let’s walk through how to take the base Slider and adapt it for our minimalistic design. #### Step 1 — Creating the wrapper We’ll start by creating `CustomSlider` in `custom-components/CustomSlider/CustomSlider.tsx.` The idea: place the slider value next to the slider using `Flex` for layout. ```tsx import Slider from "@components/Basic/Slider/Slider" import Block from "@components/Layout/Block/Block"; import Flex from "@components/Layout/Flex/Flex"; const CustomSlider = () => { return ( {3} ) } export default CustomSlider; ``` #### Step 2 — Styling Next, define the component’s slot we will modify and wire them up for styling with classes. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (2/10) ```tsx import Slider from "@components/Basic/Slider/Slider" import Block from "@components/Layout/Block/Block"; import Flex from "@components/Layout/Flex/Flex"; import style from './CustomSlider.module.scss'; const CustomSlider = () => { return ( {3} ) } export default CustomSlider; ``` With the classes wired up, we will now add some CSS to create our desired look. The changes we will make to the component are simple: new colors, hover state, removing the rounding and hiding the handle. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (3/10) ```scss .wrapper { width: 15vmax; } .value-preview { border: 0.2vh solid $primaryColor; width: 2.5vmax; padding: 0.5vmax 0; margin-right: 2vmax; text-align: center; } .slider { margin: 0; width: 10vmax; height: 1vmax; &-handle { visibility: hidden; padding: 1vmax; } &-track { background-color: $background-soft; } &-track, &-fill { border-radius: 0; } &-track { background-color: $background-soft; &:hover { background-color: $background-soft-hover; } } } ``` **Tip:** use `visibility: hidden` instead of `display: none` for the handle. Otherwise, the slider won’t register drag/click events. **Tip:** Add some padding to the hidden element to increace its area - making it easier to click and interact with. With these changes our slider shoud look like this: #### Step 3 — Making it functional The final step is to make our slider interactive by binding its value to the `Block` component that displays it. The process is straightforward and already covered in detail in [our documentation ](https://gameface-ui.coherent-labs.com/components/basic/slider/#retrieve-and-use-the-slider-value). In short, we need to: 1. Create a signal to store the current slider value. 2. Pass a callback to the slider’s `onChange` prop. 3. Update the signal inside that callback so the `Block` always shows the latest value. This setup ensures the UI is reactive - whenever the slider moves, the displayed value updates instantly. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (4/10) ```tsx import Slider from "@components/Basic/Slider/Slider" import Block from "@components/Layout/Block/Block"; import Flex from "@components/Layout/Flex/Flex"; import style from './CustomSlider.module.scss'; import { createSignal } from "solid-js"; import { emitChange } from "../../../views/menu/util"; const CustomSlider = () => { const [value, setValue] = createSignal(3); const handleChange = (newValue: number) => { setValue(newValue) emitChange() } return ( {value()} ) } export default CustomSlider; ``` The benefit of having a handler passed to the `onChange` is that we can run additional logic when the value changes. In our case we need to call a `emitChange` function which will just let us know if changes have been made to the UI (we use it to display a modal when the tab is about to change). #### Step 4 — Making it reusable --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (5/10) If you plan to use the component just once in your UI you can leave it like that and hard-code the values but in our case we need this slider in a lot of places across the UI. To achieve reusability we will add `props` to the `CustomSlider` which will need to be passed when it is initialized. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (6/10) ```tsx import Slider from "@components/Basic/Slider/Slider" import Block from "@components/Layout/Block/Block"; import Flex from "@components/Layout/Flex/Flex"; import style from './CustomSlider.module.scss'; import { createSignal } from "solid-js"; import { emitChange } from "../../../views/menu/util"; interface CustomSliderProps { step: number; min: number; max: number; value: number; onChange?: (value: number) => void; } const CustomSlider = (props: CustomSliderProps) => { const [value, setValue] = createSignal(props.value); const handleChange = (newValue: number) => { setValue(newValue) emitChange() } return ( {value()} ) } export default CustomSlider; ``` With this setup our custom slider can be modified however we see fit for the UI. This is how the `CustomSlider` will need to be initialized: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (7/10) ```tsx ``` ### Segment {#segment} The process of customizing the `Segment` component follows the same principle as with the `Slider`: wrap the base component, style its slots, and extend it with props to make it reusable. Here’s a simplified `CustomSegment` implementation: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (8/10) ```tsx import Segment from "@components/Basic/Segment/Segment" import { For } from "solid-js"; import style from './CustomSegment.module.scss'; import { emitChange } from "../../../views/menu/util"; type CustomSegmentProps = { values: V; default: V[number]; 'custom-class'?: string; onChange?: (v: V[number]) => void; ref?: any; }; export function CustomSegment(props: CustomSegmentProps) { const handleChange = (val: V[number]) => { emitChange() props.onChange?.(val); }; return ( {(v) => {v}} ) } export default CustomSegment; ``` The component styling: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (9/10) ```scss .segment { background-color: $background-soft; width: 20vmax; &-button { flex: 1; justify-content: center; background-color: transparent; color: $disabledColor; text-transform: capitalize; &:hover { color: $textColor; background-color: $background-soft-hover; } &-selected { color: $textColor; &:hover { background-color: transparent; } } } &-button::before { box-shadow: none !important; } &-button::after { background-color: $background-soft; } } ``` #### Using TypeScript for Autocomplete Notice how we have made our `CustomSegment` component is defined as a [generic function ](https://www.typescriptlang.org/docs/handbook/2/generics.html): ```ts export function CustomSegment(props: CustomSegmentProps) { ``` This lets us combine **generics + tuple types** to make the component fully type-safe and autocomplete-friendly. By declaring the values prop as a `readonly string[]`, TypeScript can infer valid options for you. The only requirement is to declare your options with the `as const` assertion: ```tsx const OPTIONS = ['PC', 'Tactical', 'Left-Handed', 'Custom'] as const; setPreset(PRESETS[v])} /> ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-glow-up/#slider] ## Gameface UI Update: Menu Glow-Up + Quick Component Customization Guide: Slider (10/10) Now, `onChange` will only accept `"PC" | "Tactical" | "Left-Handed" | "Custom"` — preventing typos and giving you IDE autocomplete for free. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/] ## Gameface UI: Adding a tutorial to the Menu UI ## Gameface UI: Adding a tutorial to the Menu UI ui tutorials 11/3/2025 Martin Bozhilov 1. Overview 2. Tutorial structure 3. Setting up the Tutorial component 1. Defining the tutorial steps 2. Initializing the Tutorial component 3. Wiring the tutorial steps 4. Adding a way to start the tutorial 1. Creating the toast 2. Creating a custom Toast body 3. Starting the tutorial 5. Providing a custom tooltip 1. Creating a custom tooltip 2. Customizing the tooltip based on the step 6. Interactive steps 1. Making the User Toggle an Option to Continue 2. Hiding the control buttons until the interactive step is completed 3. Guarding against wrong interaction 7. Conclusion In the latest [GameFace UI update ](https://gameface-ui.coherent-labs.com/changelog/#1013), we introduced a brand-new [Tutorial component ](https://gameface-ui.coherent-labs.com/components/complex/tutorial)that allows developers to create interactive tutorials within their games UIs. To demonstrate its capabilities, we revamped the Menu UI to include a tutorial that guides users through its features. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#overview] ## Gameface UI: Adding a tutorial to the Menu UI: Overview In this article, we will walk you through the steps taken to integrate the Tutorial component into the Menu UI. Explaining some of the key features of the `Tutorial` component along the way. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#tutorial-structure] ## Gameface UI: Adding a tutorial to the Menu UI: Tutorial structure The goal of the menu’s tutorial is to guide users through the main features of the Menu UI, including: - the layout structure, - the tab navigation, - the main dynamic scrollable content area, - the interactive side panel and, - the interactive components Each tutorial step focuses on one of these features, providing a short explanation and highlighting the relevant element in the interface. Some steps also include interactive actions that the user must complete before continuing. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#setting-up-the-tutorial-component] ## Gameface UI: Adding a tutorial to the Menu UI: Setting up the Tutorial component (1/4) #### Defining the tutorial steps We’ll start by defining the steps for our tutorial. To make them easy to manage and reuse, we’ll store them in a single `TutorialSteps` object. Each step defines its `order`, `title`, and `description`, and corresponds to a specific feature of the Menu UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#setting-up-the-tutorial-component] ## Gameface UI: Adding a tutorial to the Menu UI: Setting up the Tutorial component (2/4) ```ts export const TutorialSteps = { Intro: { order: 1, title: "Welcome to the Menu UI Sample", content: "This screen showcases how Gameface UI can be used to build a complete in-game settings menu.", }, Tabs: { order: 2, title: "Menu Tab Navigation", content: "We're using the Tabs and TabLinks components to handle section switching. Each tab dynamically renders its own content without reloading the layout.", }, Structure: { order: 3, title: "Layout Structure", content: "The main layout is split into two parts: the left 8 columns hold the main content, while the right 4 columns host contextual information and interactive elements.", }, Scroll: { order: 4, title: "Scrollable Container", content: "This section uses the Scroll component, which auto-adjusts its height based on the tab's content and conditionally provides a scroll handle when needed.", }, Collapsable: { order: 5, title: "Collapsible Options", content: "Some components can be expanded or collapsed. Try it out by toggling the \"Subtitles\" option.", }, Interactive: { order: 6, title: "Click the Toggle Button", content: "Enable the Subtitles option to reveal nested settings.", }, Dynamic: { order: 7, title: "Dynamic Options", content: "Notice the nested options that appeared! These settings are revealed based on parent option states.", }, InfoPanel: { order: 8, title: "Component Info Panel", content: "The right panel updates based on your selection, providing additional information and context for each menu option.", }, InteractiveTwo: { order: 9, title: "Interactive Panels", content: "Some panels have interactions that reflect changes in the menu. Try adjusting the color picker's value.", }, ColorChange: { order: 10, title: "Component Reacts to Interaction", content: "Watch how the menu item's background color updates to match the ColorPicker component's value in real-time.", }, Footer: { order: 11, title: "Static Footer Controls", content: "The footer displays a static list of keyboard shortcuts for quick navigation throughout the menu.", }, End: { order: 12, title: "End of Tour", content: "That's the overview of our Menu UI sample. Feel free to explore and extend this sample to fit your project needs.", } } as const; ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#setting-up-the-tutorial-component] ## Gameface UI: Adding a tutorial to the Menu UI: Setting up the Tutorial component (3/4) This structure keeps everything centralized — if you ever want to update a title or description, you only need to change it in one place. #### Initializing the Tutorial component Next, we initialize the `Tutorial` component at the root of the Menu UI. Since the tutorial will highlight multiple elements across the interface, it needs access to all child components. ```tsx import Tutorial, {TutorialRef} from "@components/Complex/Tutorial/Tutorial"; const Menu = () => { let tutorialRef: TutorialRef | undefined // Existing code... return ( {/* Existing Menu UI code... */} ); } ``` We attach a `ref` so the tutorial can be controlled programmatically. The `outset` prop defines how much space surrounds the highlighted element, which helps prevent overlapping visuals and keeps the focus area clean. #### Wiring the tutorial steps Each tutorial step is added by wrapping a UI section with a `` component. Every step must include an `order` (to define sequence) and can optionally include `title` and `content` to display inside the tooltip. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#setting-up-the-tutorial-component] ## Gameface UI: Adding a tutorial to the Menu UI: Setting up the Tutorial component (4/4) ```tsx {(tab) => { return {tab} }} ``` By referencing data from the `TutorialSteps` object, you keep your setup clean and consistent. This makes it easy to reorder, update, or remove steps later without touching the actual UI code. You can also fine-tune each step individually using: - `position` — manually defines where the tooltip appears relative to the highlighted element for this step only (top, bottom, left, right). - `outset` — overrides the global spacing for this specific step, letting you expand or shrink the highlight area as needed. These per-step controls are especially useful for complex layouts where elements vary in size or overlap visually. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#adding-a-way-to-start-the-tutorial] ## Gameface UI: Adding a tutorial to the Menu UI: Adding a way to start the tutorial (1/2) To let users start the tutorial manually, we added a toast that appears when the Menu UI loads. It gives users the option to either start the walkthrough or skip it entirely. #### Creating the toast We used the [Toast component ](https://gameface-ui.coherent-labs.com/components/feedback/toast/)to display this prompt. The `useToast` hook provides two key utilities - `createToast()` for spawning new toasts and `` for rendering them in the UI. ```tsx import useToast from '@components/Feedback/Toast/toast'; const Menu = () => { let tutorialRef: TutorialRef | undefined const [Toaster, createToast] = useToast(); const showToast = () => { createToast({ body: (close) => (), position: 'top-center', }); }; onMount(() => { // Existing code... showToast(); }) // Existing code... return ( {/* Existing Menu UI code... */} ); } ``` This setup shows the toast as soon as the Menu UI mounts, prompting users to begin the tutorial. For more details on toast usage, check out the [Toast documentation ](https://gameface-ui.coherent-labs.com/components/feedback/toast/#usage). #### Creating a custom Toast body Next, we built a `CustomToast` component to define the toast’s content and behavior. It receives two props: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#adding-a-way-to-start-the-tutorial] ## Gameface UI: Adding a tutorial to the Menu UI: Adding a way to start the tutorial (2/2) - close - a function that dismisses the toast when called - action - starts the tutorial when the user clicks `Start` ```tsx import { JSX } from "solid-js" import styles from './CustomToast.module.scss'; interface CustomToastProps { close: (children?: JSX.Element) => JSX.Element; action: () => void; } const CustomToast = (props: CustomToastProps) => { return (
    Start Tutorial?
    {props.close()} {props.close()}
    ) } export default CustomToast; ``` The `close` function is built into the `Toast` component - anything wrapped with it will close the toast once clicked. For the Start button, we also call `props.action()` to launch the tutorial. #### Starting the tutorial Finally, we link the `action` prop to the tutorial’s `tour()` method, which begins the walkthrough. ```tsx const Menu = () => { let tutorialRef: TutorialRef | undefined const [Toaster, createToast] = useToast(); const showToast = () => { createToast({ body: (close) => ( tutorialRef?.tour()} /> ), position: 'top-center', }); }; } ``` When the user clicks `Start`, the `tour()` method runs via the `TutorialRef`, kicking off the step-by-step guide. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#providing-a-custom-tooltip] ## Gameface UI: Adding a tutorial to the Menu UI: Providing a custom tooltip (1/5) By default, the `Tutorial` component includes a built-in tooltip that displays each step’s title and content. However, you can easily replace it with a custom tooltip to adjust its appearance or add extra functionality. #### Creating a custom tooltip To use a custom tooltip, create a component of type `TooltipType` and pass it to the tooltip prop of the `Tutorial` component. This allows you to fully control its layout and logic while still receiving all the built-in props such as `title`, `content`, `step`, `progress`, `Next`, and `Prev`. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#providing-a-custom-tooltip] ## Gameface UI: Adding a tutorial to the Menu UI: Providing a custom tooltip (2/5) ```tsx import { TooltipType } from "@components/Complex/Tutorial/TutorialTooltip" import styles from './CustomTooltip.module.scss' import Progress from "@components/Feedback/Progress/Progress" import Flex from "@components/Layout/Flex/Flex" interface CustomTooltipProps { exit: () => void; } const CustomTooltip: TooltipType = (props) => { return (

    {props.title}

    {props.content} Prev Next
    x
    ) } export default CustomTooltip; ``` In this example, the tooltip displays the current step’s title, description, and progress bar, along with navigation controls. We also added an `exit` prop, which lets users close the tutorial by clicking the “x” button. Once your component is ready, you can pass it directly to the `Tutorial` component: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#providing-a-custom-tooltip] ## Gameface UI: Adding a tutorial to the Menu UI: Providing a custom tooltip (3/5) ```tsx tutorialRef?.exit()} />}> {/* Existing Menu UI code... */} ``` #### Customizing the tooltip based on the step A custom tooltip isn’t just about visuals - it can react dynamically to tutorial state. Because it receives data such as the current `step` and `progress`, you can conditionally change its layout, visibility, or behavior. For example, you can: - Adjust its position or width on certain steps - Hide navigation buttons on the first or last step - Replace button labels dynamically (e.g., show Done instead of Next at the end) --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#providing-a-custom-tooltip] ## Gameface UI: Adding a tutorial to the Menu UI: Providing a custom tooltip (4/5) ```tsx const CustomTooltip: TooltipType = (props) => { const conditionalClasses = createMemo(() => { const classes: string[] = [styles.tooltip]; switch (props.step()) { case TutorialSteps.Intro.order: case TutorialSteps.End.order: classes.push(styles['top-offset']); break; case TutorialSteps.Structure.order: classes.push(styles.wider) break; case TutorialSteps.Interactive.order: classes.push(styles.interactive) break; } return classes.join(' '); }) return (

    {props.title}

    {props.content} Prev {props.progress() === 100 ? "Done" : "Next" }
    x
    ) } export default CustomTooltip; ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#providing-a-custom-tooltip] ## Gameface UI: Adding a tutorial to the Menu UI: Providing a custom tooltip (5/5) Here, we apply conditional classes based on the active step and modify button text when the tutorial reaches the final step. This flexibility makes it easy to create a tooltip that matches both your visual style and your UX goals. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#interactive-steps] ## Gameface UI: Adding a tutorial to the Menu UI: Interactive steps (1/5) Sometimes you’ll want users to perform an action before continuing. The `Tutorial` component supports this through programmatic pausing and resuming, letting you create interactive steps that respond to user input. #### Making the User Toggle an Option to Continue In our Menu UI tutorial, we wanted users to enable the “Subtitles” option before moving forward. To achieve this, we used the `pause()` and `resume()` methods from the `TutorialRef`. We start by attaching a `click listener` to the `Tutorial` component. When the current step matches the “Interactive” step, we call `pause()` to stop progress until the correct user action occurs. Then, we listen for a click on the Subtitles toggle - once the user interacts with it, we call `resume(true)` to continue to the next step. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#interactive-steps] ## Gameface UI: Adding a tutorial to the Menu UI: Interactive steps (2/5) ```tsx const Menu = () => { let tutorialRef: TutorialRef | undefined const [Toaster, createToast] = useToast(); const [interactiveTutorials, setInteractiveTutorials] = createSignal({ subtitles: false }) const MenuContextValue = { // Existing context values... interactiveTutorials } onMount(() => { // Existing code... showToast(); }) // Existing code... const handleClick = () => { if (tutorialRef?.current() === TutorialSteps.Interactive.order) { tutorialRef.pause(); const subtitlesToggle = document.getElementById('subtitles') subtitlesToggle?.addEventListener('click', () => { setInteractiveTutorials((prev) => ({...prev, subtitles: true})) tutorialRef.resume(true); }, { once: true }); return; } } return ( tutorialRef?.exit()} />} > {/* Existing Menu UI code... */} ); } ``` This setup ensures the tutorial pauses on the “Interactive” step and only continues once the user has completed the required action. Passing `true` to `resume()` tells the tutorial to immediately advance to the next step after resuming. #### Hiding the control buttons until the interactive step is completed --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#interactive-steps] ## Gameface UI: Adding a tutorial to the Menu UI: Interactive steps (3/5) We also created a signal called `interactiveTutorials` to track whether interactive steps are completed. This lets us conditionally hide the `Next` and `Prev` buttons in our custom tooltip until the user finishes the task. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#interactive-steps] ## Gameface UI: Adding a tutorial to the Menu UI: Interactive steps (4/5) ```tsx import { MenuContext } from "../../../views/menu/Menu" const CustomTooltip: TooltipType = (props) => { const context = useContext(MenuContext); const conditionalClasses = createMemo(() => { const classes: string[] = [styles.tooltip]; switch (props.step()) { case TutorialSteps.Intro.order: case TutorialSteps.End.order: classes.push(styles['top-offset']); break; case TutorialSteps.Structure.order: classes.push(styles.wider) break; case TutorialSteps.Interactive.order: classes.push(styles.interactive) break; } return classes.join(' '); }) // Show buttons UNLESS we're on Interactive step AND tutorial hasn't been completed yet const shouldShowButtons = () => { const isInteractiveStep = props.step() === TutorialSteps.Interactive.order; const tutorialCompleted = context?.interactiveTutorials().subtitles; if (isInteractiveStep) return tutorialCompleted return true; } return (

    {props.title}

    {props.content} Prev
    x
    ) } export default CustomTooltip; ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#interactive-steps] ## Gameface UI: Adding a tutorial to the Menu UI: Interactive steps (5/5) With this logic, navigation controls remain hidden during the “Interactive” step until the Subtitles option is enabled. This makes sure users actually complete the intended action before proceeding. #### Guarding against wrong interaction When using interactive steps, it’s important to handle cases where users navigate backward or repeat actions. For example, if the user goes back to the “Interactive” step after already completing it, clicking the toggle again could pause the tutorial unnecessarily. To prevent that, we add a simple guard that checks whether the step was already completed before calling `pause()` again. ```tsx const handleClick = () => { if (tutorialRef?.current() === TutorialSteps.Interactive.order) { if (interactiveTutorials().subtitles) return; tutorialRef.pause(); const subtitlesToggle = document.getElementById('subtitles') subtitlesToggle?.addEventListener('click', () => { setInteractiveTutorials((prev) => ({...prev, subtitles: true})) tutorialRef.resume(true); }, { once: true }); return; } } ``` Now, if the user revisits a completed interactive step, the tutorial will skip the pause logic and continue smoothly. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/gamefaceui-menu-tutorial/#conclusion] ## Gameface UI: Adding a tutorial to the Menu UI: Conclusion In this post, we walked through how to integrate the new `Tutorial` component into the Gameface UI Menu - from defining the tutorial steps and initializing the component, to building a custom tooltip and adding interactive, user-driven steps. The full implementation can be found in `src/views/Menu/Menu.tsx` within the **Gameface UI project**. Exploring the **Menu UI** sample is a great way to see how the `Tutorial` component can improve onboarding and guide users through complex interfaces with a smooth, in-context learning experience. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/] ## Creating hexagonal skill tree ## Creating hexagonal skill tree ui tutorials 1/7/2025 Martin Bozhilov 1. Source location 2. Preparing the assets 1. Hexagon SVGs 2. SkillTree background SVG 3. Setting up the project 1. Skill Tree movement 2. Creating the hexagons 4. Categorizing the skills 5. Arrange the hexagons on the skill tree 1. Mocking game data with a model object 2. Connecting model data to the html with HTML data-binding 3. Replacing the skill tree svg 6. Adding effects and animations 1. Glow effect 2. Active skill effect 3. Adding keyboard navigation 7. Making it all interactive 1. Adding tooltip with skill information 2. Adding skill unlock functionality 3. Adding error Handling 4. Quality of life improvements In this tutorial, we will explore how to create a visually appealing hexagonal skill tree inspired by the Batman: Arkham Knight game. This guide will walk you through the process of designing and implementing a skill tree using SVGs, CSS, and JavaScript. By the end of this tutorial, you’ll have a dynamic and interactive skill tree for your game. #### Source location You can find the complete sample source within the `${Gameface package}/Samples/uiresources/UITutorials/HexagonalSkillTree` directory. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#preparing-the-assets] ## Creating hexagonal skill tree: Preparing the assets Before we start coding, we need to prepare the assets for our skill tree. The easiest and most performant way to create the hexagons is by using SVGs. #### Hexagon SVGs To create the hexagons, we will head to Figma and design a hexagon shape. We will then export the hexagon as an SVG file. The simplest way to create a hexagon in Figma is by selecting the `polygon` option in the creation tool and setting the edges count to 6: And then exporting it as an SVG file from the bottom right section. #### SkillTree background SVG We will also need a background SVG for the skill tree. This SVG will serve as the base for our skill tree on which we will place the elements. We will use the hexagon we just created in Figma and duplicate it as many times as we want and after that connecting them with the pen tool. After you are done with the design, export the background SVG file. Feel free to experiment with the design and create a unique background for your skill tree. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#setting-up-the-project] ## Creating hexagonal skill tree: Setting up the project (1/5) Let’s begin by setting up the project structure, which includes adding the SVG skill tree we just created and some basic styles. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#setting-up-the-project] ## Creating hexagonal skill tree: Setting up the project (2/5) ```html
    ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#setting-up-the-project] ## Creating hexagonal skill tree: Setting up the project (3/5) ```css @font-face { font-family: 'Nunito'; src: url(./assets/Nunito-VariableFont_wght.ttf); } body{ margin: 0; width: 100vw; height: 100vh; background: linear-gradient(to bottom, #141e30, #243b55); overflow: hidden; font-family: 'Nunito'; color: white; } .container { position: absolute; right: 0; width: 75%; height: 140%; /* This transition will control the camera movement */ transition: transform 0.2s linear; z-index: -1; } ``` #### Skill Tree movement Since skill trees can be quite big we want to have the skill tree follow the mouse movement. To achieve this we will add an event listener for the `mousemove` event and update the `transform` property of the container element. We will calculate the percentage of the mouse position relative to the window size and then map it to the desired movement range. In our case we want the maxium movement to be 10% of the window width and 30% of the window height. So the maximum `translateX` value will be -10% and the maximum `translateY` value will be -30%. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#setting-up-the-project] ## Creating hexagonal skill tree: Setting up the project (4/5) ```javascript const skillTree = document.querySelector('.container'); const treePaths = document.querySelector('.svg-paths'); function translateSkillTreeIntoView(x, y) { const percentageX = (x / window.innerWidth) * 100; const percentageY = (y / window.innerHeight) * 100; const mappedX = percentageX * -0.10; const mappedY = percentageY * -0.30; skillTree.style.transform = `translateX(${mappedX.toFixed(2)}%) translateY(${mappedY.toFixed(2)}%)`; } document.addEventListener('mousemove', (event) => { const { clientX, clientY } = event; translateSkillTreeIntoView(clientX, clientY); }) ``` You SVG should now follow the mouse movement. #### Creating the hexagons Now that we have the basic structure set up, we can start creating the hexagons that will represent the skills in our skill tree. ```html
    ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#setting-up-the-project] ## Creating hexagonal skill tree: Setting up the project (5/5) One thing we changed is the separation of the svg from one `path` to six `path` elements for each side and the addition of the `strike-dash` class to the paths that we want to have a dashed stroke. We will use this class to apply a dashed stroke to the hexagon sides, creating a unique hexagon shape. **Note:** You can easily separate your hexagon svg into six different path elements for each side by provding it to an AI language model and asking it to do so. ```css .hex { width: 9vw; height: 19vh; position: absolute; transition: all 0.3s ease-in-out; display: flex; justify-content: center; align-items: center; cursor: pointer; } .hex-content { width: 70%; height: 70%; mask-size: 100%; mask-repeat: no-repeat; mask-position: center 60%; background-color: crimson; mask-image: url(./assets/strength/strength-plus.png); } .hex path { stroke: crimson; } .svg { width: 9vw; height: 19vh; position: absolute; } .svg-main path { stroke-width: 10; } .strike-dash { stroke-dasharray: 6; } ``` Our hexagon elements will consist of a hexagon SVG as the outline shape of the element and a content div that will hold the skill icon, which will be placed as a mask image. We will leverage the power of CSS masks to create different color icons for the skills while keeping the background transparent. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#categorizing-the-skills] ## Creating hexagonal skill tree: Categorizing the skills We are going to categorize the skills by their type (strength, durability, health, etc) and apply different colors to the hexagons. We can easily do that by applying different classes to the hexagon elements. And use the classes with the help of CSS variables to apply different colors to the hexagons. ```css /* Category colors */ .hex-strength { --shadow-color: crimson; } .hex-durability { --shadow-color: #FF9F43; } .hex-health { --shadow-color: #4CAF50; } .hex-mana { --shadow-color: #42A5F5; } .hex-stamina { --shadow-color: #FFEB3B; } .hex-misc { --shadow-color: #AB47BC; } /* Combined skills */ .hex-strength-durability .path-left-side { --shadow-color: crimson; } .hex-strength-durability .path-right-side { --shadow-color: #FF9F43; } .hex-health-mana .path-left-side { --shadow-color: #42A5F5; } .hex-health-mana .path-right-side { --shadow-color: #4CAF50; } /* LOCKED STATE */ .hex-locked, .hex-locked .path-left-side, .hex-locked .path-right-side { --shadow-color: #ffffff; } .hex-locked { opacity: 0.5; } ``` And now simply apply the variable to the svg `path` element. ```css .hex-skill path { stroke: var(--shadow-color); } ``` With this setup we can easily change the color of the hexagons based on the skill type as the `--shadow-color` variable will take the color from the category class placed on the parent. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (1/8) Now that we have the hexagons created, we can start placing them on the skill tree. One way to do it is to manually position each hexagon on the skill tree background SVG by setting the `left` and `top` properties of the hexagon elements untill they fit perfectly. #### Mocking game data with a model object Since we don’t have a game to provide us with the back-end data, we are going to mock some game data that will represent the skills and their relationships. We will create a mock model object that will hold all the information about the skills we need. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (2/8) ```js const SkillsModel = { points: 24, skills: [ { name: 'Health +', id: 1, description: 'Increase your max health', unlocked: false, skillPoints: 1, image: 'url(./assets/health/health-plus.png)', x: '51.5%', y: '77vh', parents: null, type: 'health', }, { name: 'Health ++', id: 2, description: 'Increase your max health', unlocked: false, skillPoints: 2, image: 'url(./assets/health/health-plus-plus.png)', x: '59%', y: '95.25vh', parents: 1, type: 'health', }, { name: 'Health +++', id: 3, description: 'Increase your max health', unlocked: false, skillPoints: 3, image: 'url(./assets/health/health-plus-plus-plus.png)', x: '66.5%', y: '113vh', parents: 2, type: 'health', }, { name: 'Mana +', id: 4, description: 'Increase your max mana', unlocked: false, skillPoints: 1, image: 'url(./assets/mana/mana-plus.png)', x: '36.5%', y: '77vh', parents: null, type: 'mana', }, { name: 'Mana ++', id: 5, description: 'Increase your max mana', unlocked: false, skillPoints: 2, image: 'url(./assets/mana/mana-plus-plus.png)', x: '29.5%', y: '95.25vh', parents: 4, type: 'mana', }, { name: 'Mana +++', id: 6, description: 'Increase your max mana', unlocked: false, skillPoints: 3, image: 'url(./assets/mana/mana-plus-plus-plus.png)', x: '22%', y: '113vh', parents: 5, type: 'mana', }, { name: 'Durability +', id: 7, description: 'Increase your max durability', unlocked: false, skillPoints: 1, image: 'url(./assets/durability/durability-plus.png)', x: '51.5%', y: '41.75vh', parents: null, type: 'durability', }, { name: 'Durability ++', id: 8, description: 'Increase your max durability', unlocked: false, skillPoints: 2, image: 'url(./assets/durability/durability-plus-plus.png)', x: '59%', y: '24.25vh', parents: 7, type: 'durability', }, { name: 'Durability +++', id: 9, description: 'Increase your max durability', unlocked: false, skillPoints: 3, image: 'url(./assets/durability/durability-plus-plus-plus.png)', x: '66.5%', y: '6vh', parents: 8, type: 'durability', }, { name: 'Stamina +', id: 10, description: 'Increase your max stamina', unlocked: false, skillPoints: 1, image: 'url(./assets/stamina/stamina-plus.png)', x: '58.75%', y: '59.5vh', parents: null, type: 'stamina', }, { name: 'Stamina ++', id: 11, description: 'Increase your max stamina', unlocked: false, skillPoints: 2, image: 'url(./assets/stamina/stamina-plus-plus.png)', x: '73.25%', y: '59.5vh', parents: 10, type: 'stamina', }, { name: 'Stamina +++', id: 12, description: 'Increase your max stamina', unlocked: false, skillPoints: 3, image: 'url(./assets/stamina/stamina-plus-plus-plus.png)', x: '87.75%', y: '59.5vh', parents: 11, type: 'stamina', }, { name: 'Strength +', id: 13, description: 'Increase your max strength', unlocked: false, skillPoints: 1, image: 'url(./assets/strength/strength-plus.png)', x: '37%', y: '41.75vh', parents: null, type: 'strength', }, { name: 'Strength ++', id: 14, description: 'Increase your max strength', unlocked: false, skillPoints: 2, image: 'url(./assets/strength/strength-plus-plus.png)', x: '29.5%', y: '23.75vh', parents: 13, type: 'strength', }, { name: 'Strength +++', id: 15, description: 'Increase your max strength', unlocked: false, skillPoints: 3, image: 'url(./assets/strength/strength-plus-plus-plus.png)', x: '22%', y: '6vh', parents: 14, type: 'strength', }, { name: 'Dodge', id: 16, description: 'Learn dodge ability', unlocked: false, skillPoints: 1, image: 'url(./assets/misc/dodge.png)', x: '29.5%', y: '59.5vh', parents: null, type: 'misc', }, { name: 'Sixth sense', id: 17, description: 'Learn the sixth sense ability and increase your awareness', unlocked: false, skillPoints: 2, image: 'url(./assets/misc/sixth-sense.png)', x: '15%', y: '59.5vh', parents: 16, type: 'misc', }, { name: 'Teleportation', id: 18, description: 'Learn the teleportation ability and unlock fast travel', unlocked: false, skillPoints: 3, image: 'url(./assets/misc/teleport.png)', x: '0.3%', y: '59.5vh', parents: 17, type: 'misc', }, ], specialSkills: [ { name: 'Iron Will', description: 'Tremendously increases strength and durability', unlocked: false, skillPoints: 5, image: 'url(./assets/combined/iron-will.png)', x: '43.75%', y: '6vh', parents: [15, 9], type: 'strength-durability', }, { name: 'Arcane Vitality', description: 'Tremendously boosts mana regeneration and health recovery', unlocked: false, skillPoints: 5, image: 'url(./assets/combined/arcane-vitality.png)', x: '44%', y: '113vh', parents: [3, 6], type: 'health-mana', }, ], starterSkill: { name: 'Journey Begins', description: 'Gain access to the skill tree', unlocked: true, skillPoints: 0, image: 'url(./assets/misc/rubber-man.png)', x: '44%', y: '59.5vh', type: 'starter', }, }; ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (3/8) And we should not forget to initialize the model in our `index.js` file. ```js function updateModel(modelName) { engine.updateWholeModel(modelName); engine.synchronizeModels(); } engine.on("Ready", () => { engine.createJSModel("SkillsModel", SkillsModel); engine.synchronizeModels(); }); ``` The model we created has a `skills` array with objects that contain the skill data, `specialSkills` array because we have special skills that require multiple skills to be unlocked, and a `starterSkill` object that represents the starting skill of the tree which will be unlocked by default. Since the url for the mask image icons will come from our mocked model, we can remove the placeholder CSS we used previously. ```css .hex-content { width: 70%; height: 70%; mask-size: 100%; mask-repeat: no-repeat; mask-position: center 60%; background-color: crimson; mask-image: url(./assets/strength/strength-plus.png); background-color: var(--shadow-color); } .hex path { stroke: crimson; } ``` Now for every category we will create a new class with different color. And also we will add a class for when the skill is locked. #### Connecting model data to the html with HTML data-binding Now that we have the model setup, we can start connecting the data to the HTML elements. We will loop through the `skills` array and create a hexagon element for each skill by utilizing the power of [data-binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/#DataBinding). --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (4/8) Since we have 3 types of skills - starter, normal and combined we will need to handle them separately. ##### Starter skill For the starter skill, we will need to extract from the model the `x` and `y` coordinates and the image url for the mask image. ```html
    ``` To make our starter skill stand out we will apply a different color to each side of the hexagon. We will use the `stroke` attribute to apply the color to the sides directly. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (5/8) ```css .hex-starter > .hex-content { background: conic-gradient( #FF9F43 0%, #FFEB3B 20%, #4CAF50 40%, #42A5F5 60%, #AB47BC 80%, crimson 100% ); } ``` And apply a `conic gradient` as the background, making it all seamlessly integrate with the stroke colors. With that, we can now see the starter skill placed in the center of our skill tree! ##### Regular skills Since we will be looping through the `skills` array we will need to create a new hexagon element for each skill. We can easily do that with the help of the `data-bind-for` attribute. The ohter notable difference from the starter skill logic is that here we will dynamically create the class name based on the skill type, which with the help of the CSS we set up earlier will apply different colors based on the categories of the skills. And finally, we will use `data-bind-class-toggle` to conditionally apply the `hex-locked` class to the hexagon element if the skill is not unlocked. This will make the hexagon appear grayed out if they are locked. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (6/8) ```html
    ``` ##### Combined skills Lastly, we will create a hexagon element for each combined skill. The combined skills will have a different color on both the left and right sides based on the category of the parent skill of each side. We will achieve that by grouping the left and right sides of the hexagon svg `path` elements and applying a class to it. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (7/8) ```html
    ``` And just as we did with the starter skill, because there will be more than one color for the background, we will add separate styles for the background of the combined skills. ```css /* Combined skills colors */ .hex-strength-durability .hex-content { background: linear-gradient(to right, crimson 0%, #FF9F43 80%); } .hex-health-mana .hex-content { background: linear-gradient(to right, #42A5F5 0%, #4CAF50 80%); } /* Locked background */ .hex-locked .hex-content{ background: #ffffff; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#arrange-the-hexagons-on-the-skill-tree] ## Creating hexagonal skill tree: Arrange the hexagons on the skill tree (8/8) And with that we have all the skills placed on the skill tree! *If you comment out the `data-bind-class-toggle` attribute you will be able to see the color categories* #### Replacing the skill tree svg Now that we have all the skills placed on the skill tree, we can remove the hexagons that we placed our elements upon and preserve only the lines connecting them. Achieving this is very simple, we just need to head to Figma again and export the skill tree without the hexagons. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (1/11) To make our colorful skill tree even more engaging we can add some effects and animations to the hexagons. #### Glow effect To enhance the visual appeal of the skill tree we can add a glow effect to the hexagons making them more futuristic. Doing that is very simple, we just need to add a `filter` property to the svg hexagon element. ```css .svg-main { filter: drop-shadow(0 0 5px var(--shadow-color)) drop-shadow(0 0 20px var(--shadow-color)); } ``` Each hexagon will now have a glow effect that will change color based on the category of the skill. We also need to handle the combined skills and the starter skill separately. ```css /* Combined skills glow */ .svg-main.hex-strength-durability { filter: drop-shadow(0 0 5px #FF9F43) drop-shadow(0 0 5px crimson) } .svg-main.hex-health-mana { filter: drop-shadow(0 0 5px #42A5F5) drop-shadow(0 0 5px #4CAF50) } /* Only for specificity */ .hex-locked .hex-strength-durability.svg-main, .hex-locked .hex-health-mana.svg-main { filter: drop-shadow(0 0 5px #ffffff) drop-shadow(0 0 5px #ffffff) } ``` The starter skill will have a different glow effect. We want each side of the hexagon to have a different glow color. Unfortunately, we can’t apply filter to a path element, so the approach we will go for is to put 2 of the same SVGs in the `hex-content` element and blur them, making the effect of a glow. In the `hex-starter` element, inside `hex-content` we will add the following html: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (2/11) ```html
    ``` And the following CSS: ```css .svg-starter-glow { filter: blur(10px); } .svg-starter-glow.outer { transform: scale(1.02); } .svg-starter-glow.inner { transform: scale(0.98); } ``` #### Active skill effect --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (3/11) When a skill is hovered or selected we can add a unique animation making it stand out from the rest: Let’s begin by firstly modifying the hex elements by adding a couple of SVGs again inside the `hex-content` element. To decrease the amount of code, we are going to once again use `data-bind-for` to render the inner svgs that will be used for the animation. ```js engine.on("Ready", () => { engine.createJSModel("SkillsModel", SkillsModel); engine.createJSModel("SvgModel", SvgModel); ``` And we should also create the model like so: ```js const SvgModel = { innerSvgs: [1,2,3], } ``` Starter hex: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (4/11) ```html
    ``` Regular skills: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (5/11) ```html
    ``` Combined skills: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (6/11) ```html
    ``` We will now use the `svg-outer` and `svg-inner` classes to apply different kinds of animations for each SVG. Let’s create a second CSS file to put our animations in as to not polute the global one. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (7/11) ```css @keyframes inner-shrink-1 { 0% { transform: scale(1); } 100% { transform: scale(0.9); } } @keyframes inner-shrink-2 { 0% { transform: scale(0.95); } 100% { transform: scale(0.85); } } @keyframes inner-shrink-3 { 0% { transform: scale(0.95); } 100% { transform: scale(0.8); } } @keyframes outer-glow { 0% { filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.51)) blur(5px); stroke-width: 10; opacity: 1; } 25% { filter: drop-shadow(0 0 30px rgba(0, 0, 0, 0.51)) blur(15px); stroke-width: 50; } 90% { transform: scale(1.25); opacity: 0.25; stroke-width: 20; } 100% { opacity: 0; stroke-width: 0; transform: scale(1.3); } } ``` Unfortunately, CSS variables can’t be used in keyframes, so we will have to set some default colors for the animations. Now let’s add the animations to the hexagons: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (8/11) ```css /* Outer shadow */ .selected { transform: scale(1.1); } .svg-outer { position: absolute; top: 0; left: 0; display: none; } .selected .svg-outer { animation: outer-glow 1.5s infinite ease-in; display: block; } /* Inner animation svg */ .svg-inner { position: absolute; top: 0; left: 0; stroke-width: 4; opacity: 0.5; display: none; } .selected.svg-inner { display: block; } .svg-inner-1 { animation: inner-shrink-1 0.75s infinite alternate ease-in-out; } .svg-inner-2 { stroke-width: 7; opacity: 0.75; animation: inner-shrink-2 0.75s infinite alternate ease-in-out; } .svg-inner-3 { animation: inner-shrink-3 0.75s infinite alternate ease-in-out; } ``` We added a `selected` class to apply and run the animations only on the currently selected element. We can now add the `selected` class to the hexagon element and its SVGs when it is hovered or clicked. We will again utilize the power of [data-binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/#DataBinding)to easily attach events to our skill tree items. For more seаmless state management, we are going to create [an observable model ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/#observable-models)which will automatically update when its state changes. After initialzing it we are going to set its value as our starter skill. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (9/11) ```js engine.on("Ready", () => { engine.createJSModel("SkillsModel", SkillsModel); engine.createJSModel("SvgModel", SvgModel); engine.createObservableModel("activeState"); engine.addSynchronizationDependency(SkillsModel, activeState); activeState.activeSkill = SkillsModel.starterSkill; ``` Starter skill: ```html
    ``` Other skills: ```html
    > ``` As you can see, we’ve added a `data-bind-focus` attribute to the hexagon element. This attribute will call the `makeActive` function when the element is focused. The `makeActive` function will expect the DOM element and the skill object from the model as arguments and there we will handle which element is active. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (10/11) ```js function focusElement(element) { element.focus(); } function makeActive(skillElement, skill) { if(skillElement.classList.contains('selected')) return activeState.activeSkill = skill; engine.synchronizeModels(); } ``` Like that, the code will almost work, what’s left is to make each of our hexagons focusable. #### Adding keyboard navigation We are going to use Gameface’s [Interaction manager ](https://coherentlabs.github.io/GameUIComponents/en/interaction-manager)library and more specifically the [Spatial navigation ](https://coherentlabs.github.io/GameUIComponents/en/interaction-manager/spatial-navigation/)to make our hexagons focusable and to easily extend our sample with keyboard navigation. After installing it and putting it in our project, what’s left is to initialize it in our `index.js` file. ```js function initSpatialNavigation() { interactionManager.spatialNavigation.init(['.hex'], 0.3); interactionManager.spatialNavigation.focusFirst(); } ``` Here we say that we want to make all elements with the class `hex` focusable and that we want to allow a maximum of 30% overlap between the current item and the others when deciding which element to focus next. You can find out more about this parameter in the [documentation ](https://coherentlabs.github.io/GameUIComponents/en/interaction-manager/spatial-navigation/#overlap-optional). The only thing left is to call this function after the model has loaded in the `Ready` event. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#adding-effects-and-animations] ## Creating hexagonal skill tree: Adding effects and animations (11/11) ```js engine.on("Ready", () => { engine.createJSModel("SkillsModel", SkillsModel); engine.synchronizeModels(); initSpatialNavigation(); }); ``` And that’s it! Now you can navigate through the hexagons using the keyboard arrows and see the active element animation respond. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (1/11) Now that we have our skill tree set up, we can start making everything interactive and input responsive. #### Adding tooltip with skill information We are going to add a tooltip to display the skill’s information when the user hovers over a skill and a skill points counter to keep track of the available skill points the player has. The tooltip will consist of the following elements: - Skill name - Skill cost - Skill description - Unlocked status that will show dynamically based on the skill’s unlocked state. We are once again going to make use of the observable model that keeps track of the active element. Having this information we can use `data-binding` to fill out the `textContent` of the elements we need with the properties of the currently active element. ```html

    unlocked
    ``` Now to add the styles --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (2/11) ```css .skill-info { position: absolute; top: 2.5%; left: 1%; padding: 1.5vmax 1.25vmax; width: 30%; background: rgba(0, 0, 0, 0.8); color: white; border-radius: 10px; box-shadow: 0 0 20px 3px var(--shadow-color); transition: box-shadow 0.5s; } .hex-locked.skill-info { opacity: 0.8; } .hex-starter.skill-info, .hex-strength-durability.skill-info, .hex-health-mana.skill-info { background-color: black; } .hex-strength-durability.skill-info { --shadow-color: crimson; --shadow-color-2: #FF9F43; } .hex-health-mana.skill-info { --shadow-color: #42A5F5; --shadow-color-2: #4CAF50; } /* Reset for locked state */ .hex-locked.skill-info { --shadow-color: #FFF; } .hex-starter.skill-info::before, .hex-strength-durability.skill-info::before, .hex-health-mana.skill-info::before { content: ''; position: absolute; top: -5px; left: -5px; right: -5px; bottom: -5px; z-index: -1; border-radius: 10px; filter: blur(10px); background-image: linear-gradient(to right, var(--shadow-color), var(--shadow-color-2)); } .hex-starter.skill-info::before { background: linear-gradient(to right, #FF9F43, #FFEB3B, #4CAF50, #42A5F5, #AB47BC, crimson); } /* Reset for locked state */ .hex-locked.skill-info::before { background-image: none; } .skill-name { border-bottom: 2px solid rgba(255, 255, 255, 0.5); font-size: 1.6vmax; margin: 0; margin-bottom: 1vmax; padding-bottom: 1vmax; text-transform: uppercase; } .skill-price { text-transform: uppercase; font-size: 1.7vmax; margin-bottom: 1vmax; color: var(--shadow-color); filter: drop-shadow(0 0 10px var(--shadow-color)); transition: filter 0.5s, color 0.5s; } .skill-price.hidden { display: none; } .skill-description { font-size: 0.9vmax; } .skill-points { position: absolute; bottom: 2.5%; left: 1%; display: flex; font-size: 3vmax; } .skill-status { color: white; letter-spacing: 10px; font-size: 1.2vmax; text-transform: uppercase; text-align: center; margin-top: 2vmax; position: relative; transform: translateX(-100%); opacity: 0; transition: transform 0.3s, opacity 0.3s; } .skill-status.unlocked { transform: translate(0); opacity: 1; } .skill-status::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--shadow-color); opacity: 0.5; z-index: -1; border: 1px solid white; transition: background-color 0.5s; } /* starter skill status */ .hex-starter .skill-status::before { background: linear-gradient(to right, #FF9F43, #FFEB3B, #4CAF50, #42A5F5, #AB47BC, crimson); } /* Combined skills status */ .hex-strength-durability .skill-status::before, .hex-health-mana .skill-status::before { background-image: linear-gradient(to right, var(--shadow-color), var(--shadow-color-2)); } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (3/11) The idea is to have the tooltip correspond to the skill category and also have a glow effect. We achieved this by using `box shadows` for the regular skills and `linear gradients` for the starter and combined skills. Now when you hover over a skill, you will see the tooltip with the skill’s information dynamically updating upon interaction. #### Adding skill unlock functionality In order to make the interaction with the skill tree more engaging, we will make the paths connecting the skills fill with the corresponding color of the skill’s category when a skill is unlocked. We will slightly modify the SVG paths by giving them category classes, as well as a class that will help us keep track of which path corresponds to which skill of the category, essentially making each path have a unique class that will help us identify when to color its stroke. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (4/11) ```html ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (5/11) Let’s apply the styles to the paths, as well as handle the transition for when the stroke is filled. ```css .hex-path { stroke: var(--shadow-color); transition: all 0.3s ease-in; } ``` With that out of the way we are now ready to combine the skill unlock functionality with the skill tree. In the `index.js` file we will add an `unlockSkill` function that will handle all the logic. ```js function unlockSkill(skillElement, skill, combined = false) { const {type, skillPoints, parents, unlocked} = skill; skillElement.focus(); if (unlocked) return; if(skillPoints > SkillsModel.points || !isSkillValid(parents, skill)) { return; }; skillElement.classList.remove('hex-locked'); SkillsModel.points -= skillPoints; skill.unlocked = true; updateModel(SkillsModel); if(combined) { const paths = skillTree.querySelectorAll(`.${type}`); if (paths) paths.forEach((path) => path.classList.remove('hex-locked')); } else { const path = skillTree.querySelector(`.${type}-${skillPoints}`); if (path) path.classList.remove('hex-locked'); } } function isSkillValid(parents, skill) { if(parents === null) return true; if (Array.isArray(parents)) return skill.parents.every((parentId) => SkillsModel.skills[parentId - 1].unlocked); return SkillsModel.skills[skill.parents - 1].unlocked; } ``` In the `unlockSkill` function we do the following: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (6/11) - Check if the skill is already unlocked - Check if the player has enough skill points to unlock the skill - Check if the skill’s parent is unlocked - If all the conditions are met, we set the unlocked field in the model to true, update the model, and remove the `hex-locked` class from the skill element and the corresponding path to fill the svg’s path with color. We also added the `isSkillValid` helper function that will help us determine if the skill’s is valid for unlocking. - Normal skill is considered valid if the parent is unlocked - Combined skill is considered valid if both parents are unlocked Lastly we need to connect the `unlockSkill` function with our hexagon elements. The logic for unlocking will trigger when the element is clicked or the key ‘Enter’ is pressed. ```html
    ``` For the combined skills, it’s the same as the regular skills, but we need to pass an additional argument to the `unlockSkill` function to indicate that the skill is combined. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (7/11) ```html
    ``` Lastly, we need to handle the key press event for the ‘Enter’ key within the `handleKeyPress` function. Its logic is simple - if the ‘Enter’ key is pressed, we call the `unlockSkill` function. ```js function handleKeyPress(skillElement, event, skill, combined = false) { if(event.charCode !== 13) return unlockSkill(skillElement, skill, combined) } ``` And that’s it! Now you can interact with the skill tree by unlocking the skills and seeing the paths, skills and the tooltip fill with color. #### Adding error Handling As you have probably noticed, clicking on a skill that is locked and doesn’t meet the requirements will not show a visual cue. We should notify the player that the skill can’t be unlocked and why. We will add a subtle locked animation to the skill element and display an error message. For displaying the error message, we will use [Gameface’s toast ](https://coherentlabs.github.io/GameUIComponents/en/components/toast/)component. **Click if unsure how to add it to your project** First, we need to install it. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (8/11) ```bash npm i coherent-gameface-toast ``` After installing it, we need to add the toast component to our project. Let’s first add the toast’s styles. We will add them before our custom styles, so they can be easily overwritten. ```html ``` And the toast’s script ```html ``` Let’s add the toast to our `index.html` file. ```html
    Can't unlock
    ``` Now let’s customize the toast’s styles to fit the theme of our project. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (9/11) ```css /* Error message */ .guic-toast-container { overflow: visible; } .toast-slide-in { animation-name: slide-in; animation-duration: 0.5s; } .toast-slide-in-retrigger { animation-name: slide-in-retrigger; animation-duration: 0.5s; } .guic-toast-hide { animation-name: guic-toast-fade-out; } .guic-toast { background: rgba(0, 0, 0, 0.8); color: white; border-radius: 10px; box-shadow: 0 0 20px 3px crimson; padding: 0.2vmax; } .guic-toast-message { padding: 0.5vmax; } .error-message-header { background-color: rgba(220, 20, 60, 0.5); padding: 0.3vmax 0.5vmax; margin-bottom: 0.3vmax; text-transform: uppercase; border: 1px solid white; } /* disable since we are not using it */ .guic-toast-close-btn { display: none; } ``` And add a custom `slide-in` animation for the toast, overwritting the default one. ```css @keyframes slide-in { 0% { transform: translateX(50vmax); } 50% { transform: translateX(-5vmax); } 100% { transform: translateX(0%); } } @keyframes slide-in-retrigger { 0% { transform: translateX(50vmax); } 50% { transform: translateX(-5vmax); } 100% { transform: translateX(0%); } } ``` The reason we added 2 animation that do the same thing is because we want to be able to retrigger the animation if the toast needs to be shown again before the previous one has finished. Now let’s add the logic for showing the error message. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (10/11) ```js const toast = document.querySelector('gameface-toast'); const toastMessage = toast.querySelector('.error-message'); function showErrorMessage(skillPoints) { toastMessage.textContent = skillPoints > SkillsModel.points ? 'Not enough skill points' : 'Parent skill not unlocked'; if(toast.visible) { toast.classList.toggle('toast-slide-in'); toast.classList.toggle('toast-slide-in-retrigger'); } toast.show(); } ``` The other visual indicator for invalid operation is the locked animation on the skill element. We will add a simple animation that will make the skill element shake when the player tries to unlock a locked skill. ```css @keyframes shake { 25% { transform: translateX(2.5%); } 50% { transform: translateX(-2.5%); } } ``` Apply it to the hex elements ```css .hex.shake{ animation: shake 0.5s ease-in-out; } ``` What’s left is to add a function to trigger the animation and combine it with the toast error message in the `unlockSkill` function. ```js if (skillPoints > SkillsModel.points || !isSkillValid(parents, skill)) { showErrorMessage(skillPoints); triggerLockedAnimation(skillElement); return; }; function triggerLockedAnimation(skillElement) { skillElement.classList.add('shake'); setTimeout(() => skillElement.classList.remove('shake'), 500); } ``` Now we have a fully interactive skill tree with error handling and visual cues for the player! #### Quality of life improvements --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hexagon-skill-tree/#making-it-all-interactive] ## Creating hexagonal skill tree: Making it all interactive (11/11) Our skill tree is almost complete, but there is one quality of life improvement we can add to make the experience even better. Currenly, if the player decided to navigate the tree using only the keyboard, the screen won’t follow them like it would if they were using the mouse. We can fix this by enhancing the `makeActive` function by calling the `translateSkillTreeIntoView` function and providing it with the coordinates of the active skill. ```js function makeActive(skillElement, skill) { if(skillElement.classList.contains('selected')) return activeState.activeSkill = skill; engine.synchronizeModels(); const skillRect = skillElement.getBoundingClientRect(); const skillTreeRect = skillTree.getBoundingClientRect(); // Coordinates relative to the skill tree const x = skillRect.x - skillTreeRect.x; const y = skillRect.y - skillTreeRect.y; translateSkillTreeIntoView(x, y); } ``` In order to properly calculate the correct x and y coordinates, we have to subtract the position of the skill element from the position of the skill tree. That way we get the correct coordinates relative to the viewport and not the tree SVG. And with that our skill tree is complete! ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/] ## Hologram UI (1/3) ## Hologram UI ui tutorials 3/28/2024 Veneta Kochovska This guide shows how to create a hologram effect like this one in Gameface: It uses CSS [transform ](https://developer.mozilla.org/en-US/docs/Web/CSS/transform), [filters ](https://developer.mozilla.org/en-US/docs/Web/CSS/filter), [animations ](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations)and [box-shadow ](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow)to achieve the glowing, transparent look with the moving particles. The skewed circles are SVGs that have transform applied to them: ```html ``` The `.ellipse` class has [rotate3d ](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d): ```css .ellipse { transform: rotate3d(1, 0, 0, 84deg); } ``` The shadow underneath the ellipses are div elements with `box-shadow`: ```css .projector-circle-bottom { position: absolute; top: 439px; width: 150px; height: 120px; border: 2px transparent; border-radius: 150px; box-shadow: 0px 50px 100px 30px #00a6ffcc; } ``` And they too have the `.ellipse` class which applies the transformation. The light beams are absolutely positioned div elements that have [box-shadow ](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow)which creates the specific glow transparent effect: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/] ## Hologram UI (2/3) To achieve pointy edges we use four vertically aligned elements that have different values for [blur and spread-radius ](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow#syntax): ```html
    ``` `glow-middle` has higher value for blur-radius giving it a bigger shadow, making the center of the light beam wider. And respectively `glow-edge` has a narrower shadow. ```css .glow-edge { width: 1px; height: 60px; background-color: rgb(0, 166, 255, 0.5); box-shadow: 0px 0px 55px 10px rgb(0, 166, 255, 0.5); } .glow-middle { width: 1px; height: 60px; background-color: rgb(0, 166, 255); box-shadow: 0px 0px 80px 20px rgb(0, 166, 255, 1); } ``` The slightly lighter light beams have separate class `.highlight` that uses different color for the box shadow: ```css .highlight .glow-edge { background-color: rgb(129, 222, 255, 1); box-shadow: 0px 0px 100px 20px rgb(230, 249, 254, 0.7); } ``` The image is an SVG with the logo that uses a CSS filter to change the color: ```css .hologram-bg { background: url(./assets/Master_full_white.svg); background-repeat: no-repeat; background-size: contain; filter: invert(29%) sepia(66%) saturate(1878%) hue-rotate(175deg); } ``` The particle effects are generated using JavaScript and animated using CSS animation. Each particle has box-shadow that adds the glow effect: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/] ## Hologram UI (3/3) The `generateParticles(count, diameterBoundaries, coordBoundaries)` accepts 3 arguments: - the number of particles you want to generate - an array of lower and upper limit of the diameter - an array of lower and upper limit of the position coordinates Example: ```javascript generateParticles(20, [2, 8], [150, 150]); ``` Will generate 20 particles with random size ranging from 2 to 8 pixels and will position them with top and left randomly chosen, not exceeding 150. ```css .particle { background-color: rgba(208, 235, 250, 0.5); box-shadow: 0px 0px 20px 10px rgb(0, 166, 255, 0.5); } ``` The size of the particles is dynamic but within a given range. The position is also random, but again - within the boundaries of a container element. Each particle is a square div with border radius equal to its width to make it a circle. The animation is a vertical movement from the starting position to the top of the parent container: ```js function generateParticleAnimation(initialPosition, idx, animClassName) { const animName = `particle-anim-${idx}`; return ` .${animClassName} { animation-duration: 6s; animation-name: ${animName}; animation-iteration-count: infinite; animation-timing-function: linear; } @keyframes ${animName} { 0% { top: ${initialPosition}px; opacity: 1; } 50% { top: 10px; opacity: 0; } 100% { top: ${initialPosition}px; opacity: 1; } }`; } ``` ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/] ## In-world hologram UI - Showing a tooltip in game (Part 1) ## In-world hologram UI - Showing a tooltip in game (Part 1) ui tutorials 12/17/2024 Kaloyan Geshev 1. Showcase Overview 2. Getting started 3. Setting up Gameface and game level in Unreal 4. Adding third person to our project 5. Creating a HUD class 6. Setting up a Gameface view 7. Setting a game mode override 8. Implementing the tooltip UI 9. Preparing the tooltip state in the game 10. Adding a trigger box 11. Creating an actor for the tooltip 12. Create variables for the tip state and gameface hud 13. Create data model for the tip 14. Updating the tip state method 15. Update the tip visible state method 16. Toggling tooltip visibility 17. Updating the position of the tooltip 18. Result 19. What is next? In this tutorial series, we’ll build a game featuring in-world UI elements similar to the one used in *Dead Space*. To provide a comprehensive guide and a fully functional game, the tutorial is split into multiple parts. You can find the complete **Hologram UI series** here. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#showcase-overview] ## In-world hologram UI - Showing a tooltip in game (Part 1): Showcase Overview To give you a better idea of what we’ll create, let’s briefly review the game and its UI features: 1. The main player will use the `Third Person Character` from Unreal Engine. 2. A `trigger box` will display a tooltip when the player enters, instructing them on which key to press to open an inventory menu. The inventory will appear directly in the game world. 3. A `message screen` above the trigger box will be visible for the player notifying that inventory access is available when they approach the area. 4. A 3D `inventory UI` will pop up when the player presses `P` while inside the trigger box. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#getting-started] ## In-world hologram UI - Showing a tooltip in game (Part 1): Getting started In the first part of the series, we’ll cover points 1 and 2: - Adding the Third Person Character to the project. - Creating a trigger box that displays a tooltip when activated. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#setting-up-gameface-and-game-level-in-unreal] ## In-world hologram UI - Showing a tooltip in game (Part 1): Setting up Gameface and game level in Unreal To get started, we need to integrate `Gameface` with Unreal Engine. Follow the steps in our official [documentation ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/). You can add Gameface to an existing project or create a new one. For this tutorial, we’ll use the sample project from the Gameface plugin and create a new level named `HologramUI`. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#adding-third-person-to-our-project] ## In-world hologram UI - Showing a tooltip in game (Part 1): Adding third person to our project To include the Third Person Character in your project: 1. Open the `Content Browser`. 2. Click the `Add` button and select `Add Feature or Content Pack`. 3. Choose `Third Person` from the list. 4. Click `Add to Project`. Once added, you’ll see a new folder for the Third Person Character in your project structure. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#creating-a-hud-class] ## In-world hologram UI - Showing a tooltip in game (Part 1): Creating a HUD class Next, we will create a HUD class to set up a new Gameface view for displaying tooltips. To do that we will create a new hud blueprint class. 1. Navigate to the `Content/MapAssets` folder in the `Content Browser`. 2. Click the `Add` button and select `Blueprint Class`. 3. Search for `Gameface GameHud` or `CohtmlGameHUD`, and select it. 4. Name the class `CoherentSampleHologramBP`. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#setting-up-a-gameface-view] ## In-world hologram UI - Showing a tooltip in game (Part 1): Setting up a Gameface view Once the HUD class is created, configure it in the `Event Graph` of `CoherentSampleHologramBP`. - Ensure `Receive Input` is unchecked, as the HUD view will only display tooltips without user interaction. - Add a `Setup Input` function to spawn the `CohtmlInputActor` when the game starts, enabling input control for other in-world UI elements. This will be used in later parts of the series. The `Setup Input` function will have the following implementaion in the blueprint: Next, create an `HTML` page for the HUD in the `Content/uiresources/HologramUI` folder. Name the file `hud.html`. We’ll modify it in later steps. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#setting-a-game-mode-override] ## In-world hologram UI - Showing a tooltip in game (Part 1): Setting a game mode override Before implementing the tooltip UI, we will set up a Game Mode Override. 1. Create a new blueprint class in the `Content/MapAssets/HologramUI` folder, similar to the HUD class. 2) Assign the following values: - `HUD Class`: `CoherentSampleHologramBP` - `Default Pawn Class`: `BP_ThirdPersonCharacter` 3) Save the settings and select the new Game Mode Override in the `World Settings`. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#implementing-the-tooltip-ui] ## In-world hologram UI - Showing a tooltip in game (Part 1): Implementing the tooltip UI (1/3) The tooltip UI will be implemented in the file located at `Content/uiresources/HologramUI/hud.html`. To start, create HTML elements for the tooltip with a wrapper that includes data-binding attributes. These attributes will allow the tooltip’s position to dynamically adjust based on changes in the game’s data model. Later, an actor will be positioned in the game editor to serve as an anchor for the tooltip. This ensures that the tooltip maintains its position relative to the player’s camera. For now, we’ll focus on setting up the data binding and including the `cohtml.js` library. Later, in the game, we’ll also create a model called `tipState` to manage the tooltip’s visibility and position. ```html
    P
    Open inventory
    ``` Here’s how the attributes are used: - `data-bind-if`: Displays the tooltip only when necessary. - `data-bind-style-left` and `data-bind-style-top`: Dynamically adjust the tooltip’s position based on the player’s camera. Additionally, the `overlay-lines` element simulates a noise effect. This animation is created using a similar technique to the one described in the Tetris UI in World tutorial. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#implementing-the-tooltip-ui] ## In-world hologram UI - Showing a tooltip in game (Part 1): Implementing the tooltip UI (2/3) Next, create a new CSS file, `hud-styles.css`, in the `Content/uiresources/HologramUI` directory. This file will define the tooltip’s appearance and animations. ```css html, body { perspective: 1000px; margin: 0; width: 100vw; height: 100vh; } .overlay, .overlay-lines { position: absolute; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; z-index: 999; } .overlay-lines { background-image: linear-gradient(rgba(0, 200, 228, 0.1) 0%, rgba(0, 200, 228, 0.1) 30%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 100%); background-size: 100% 0.5rem; animation: overlay-anim 3s forwards linear infinite; } @keyframes overlay-anim { from { background-position: 0% 0%; } to { background-position: 0% -10%; } } .tip { width: 10rem; height: 3.2rem; position: absolute; display: flex; flex-direction: row; align-items: center; justify-content: center; font-weight: bold; color: rgba(0, 201, 228, 1); } .tip-key { position: relative; width: 3.2rem; height: 3.2rem; border-radius: 5rem; background-color: rgba(0, 201, 228, 0.5); border: 0.2rem solid rgba(0, 201, 228, 0.5); } .key { width: 100%; height: 100%; font-size: 2rem; display: flex; flex-direction: row; align-items: center; align-content: center; justify-content: center; } .tip-message { font-size: 1.2rem; margin-left: 0.4rem; } ``` Finally, link the newly created stylesheet in the `hud.html` file: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#implementing-the-tooltip-ui] ## In-world hologram UI - Showing a tooltip in game (Part 1): Implementing the tooltip UI (3/3) ```html Document
    P
    Open inventory
    ``` The noise effect is achieved using the `background-image` property with a linear gradient that continuously scrolls upward. This creates the noise effect, adding a polished touch to the tooltip UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#preparing-the-tooltip-state-in-the-game] ## In-world hologram UI - Showing a tooltip in game (Part 1): Preparing the tooltip state in the game With the tooltip UI already created, it’s time to set up the game logic and models needed to display it on the screen. We will start by creating a new structure under `Content/MapAssets/HologramUI` to represent the tooltip state required for its model `tipState`, used in the UI. Name this structure `TipState`. The structure will include the following properties: 1. **`x` (Float)**: The tooltip’s X-axis position, calculated in the 2D space of the game screen. 2. **`y` (Float)**: The tooltip’s Y-axis position, calculated in the 2D space of the game screen. 3. **`visible` (Boolean)**: Determines whether the tooltip is visible. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#adding-a-trigger-box] ## In-world hologram UI - Showing a tooltip in game (Part 1): Adding a trigger box To control the visibility of the tooltip, we need to add a trigger box to the map. When the player enters the trigger box area, the tooltip will be displayed. We’ll show you how to display the tooltip in the next tutorial. For now we’ll continue with creating the rest of the scene. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#creating-an-actor-for-the-tooltip] ## In-world hologram UI - Showing a tooltip in game (Part 1): Creating an actor for the tooltip To align the tooltip’s position in the game with its coordinates in the UI, we will need to create a static actor in the level. This actor will serve as a reference for calculating the tooltip’s UI position. The steps to create the actor are the following: 1. Add a new actor to the level and name it `Tip`. 2. Position the actor at the center of the trigger box. 3. Assign a tag (e.g., `tip`) to the actor in the `Details Panel` so that we are able to easily identify our actor later. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#create-variables-for-the-tip-state-and-gameface-hud] ## In-world hologram UI - Showing a tooltip in game (Part 1): Create variables for the tip state and gameface hud With the stage setup complete, we can now proceed to the game logic. Start by creating a new function in the Level Blueprint called `Init Variables`. This function will initialize all the variables required for the Level Blueprint. For now, we’ll focus on initializing the `Gameface HUD` and `Tip` variables - The `Tip` variable should reference the static actor created earlier with the `tip` tag. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#create-data-model-for-the-tip] ## In-world hologram UI - Showing a tooltip in game (Part 1): Create data model for the tip Once the `Init Variables` function is ready, we can proceed with configuring the game model for the UI. In the Level Blueprint, on `Event BeginPlay`: 1. Call `Init Variables` to initialize all required variables. 2. Set up the `Tip State` model when Gameface bindings are ready. Additionally, perform the following steps during this stage: 1. Initialize the Input Actor - Create a variable for the `Input Actor` that Gameface spawns at the start of the game. This actor will be used later to focus different UI views. It’s best to set it up now, as it is spawned once the Gameface bindings are ready. 2. Add a Boolean for the Bindings - Create a boolean variable named` Are Bindings Ready`. This will be used as a conditional check to ensure the UI models can be updated from the game. Without this check, attempts to update the models before the bindings are ready will fail. Next, use `Create Data Model From Struct` followed by `Synchronize Models` to create the `tipState` model from the `Tip State` structure. This structure was defined earlier and is used in the `hud.html` page. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#updating-the-tip-state-method] ## In-world hologram UI - Showing a tooltip in game (Part 1): Updating the tip state method To manage updates to the tip state, create a dedicated function in the Level Blueprint called `Update Tip State`. 1. Function Inputs - Add three inputs: `x`, `y`, and `visible`. Their data types should match the corresponding fields in the `Tip State structure`. 2. Update the Structure Members - Modify the fields of the `Tip State` structure with the values passed into the function. 3. Synchronize the Data Model - Update the data model linked to the `Tip State` structure, identified by the name `tipState`. Call `Synchronize Models` to ensure the UI is updated correctly, displaying the tooltip with the new values. By following these steps, the tooltip will dynamically reflect changes in the UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#update-the-tip-visible-state-method] ## In-world hologram UI - Showing a tooltip in game (Part 1): Update the tip visible state method To simplify the process, we will create a dedicated method to update only the visibility state of the tooltip. This method will be similar to the one that updates the entire state but focuses solely on visibility. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#toggling-tooltip-visibility] ## In-world hologram UI - Showing a tooltip in game (Part 1): Toggling tooltip visibility Next, we’ll modify the tooltip’s visibility so that it appears when the player enters the trigger area of the trigger box and disappears when they leave. To achieve this, we’ll use the `On Actor Begin Overlap (TriggerBox)` and `On Actor End Overlap (TriggerBox)` events, which can be accessed in the Level Blueprint: 1. Right-click in the Level Blueprint editor. 2. Navigate to `Add Event for Trigger Box 0 > Collision`. Once the events are set up, call the `Update Tip Visible State` method to toggle the tooltip’s visibility in the UI. This ensures the tooltip becomes visible when the player enters the trigger box and hides when the player exits. Additionally, include a check to confirm that the bindings are ready. This prevents errors if the player interacts with the trigger box before the bindings are initialized. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#updating-the-position-of-the-tooltip] ## In-world hologram UI - Showing a tooltip in game (Part 1): Updating the position of the tooltip The final step is to dynamically update the tooltip’s position as the player moves within the trigger area of the box. To achieve this, perform the following actions on each tick: 1. Ensure the bindings are ready to prevent errors. 2. Translate the `Tip` actor’s 3D coordinates to 2D based on the player’s screen viewport. 3. Update the tooltip’s position in the UI model so it moves in sync with the `Tip` actor’s location in the game. For converting the `Tip` actor’s position from 3D to 2D: 1. Retrieve the actor’s location in the game world. 2. Project its position onto the screen coordinates using the relevant Unreal Engine functions. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#result] ## In-world hologram UI - Showing a tooltip in game (Part 1): Result Once we’ve completed all the steps, the tooltip will behave in the following way: - It appears when the player enters the trigger area. - It updates its position dynamically based on the player’s movement. - It disappears when the player exits the trigger area. Here’s an example of the final result: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-1/#what-is-next] ## In-world hologram UI - Showing a tooltip in game (Part 1): What is next? In the next tutorial, we’ll learn how to create an in-world visual indicator above the trigger box, showing the player that they can access their inventory by pressing the `P` key. Check it out here: Hologram UI Tutorial - Part 2. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/] ## In-world hologram UI - Showing an in world screen with a message (Part 2) ## In-world hologram UI - Showing an in world screen with a message (Part 2) ui tutorials 1/7/2025 Kaloyan Geshev 1. Showcase Overview 2. Adding an in-world view 1. Creating the In-World Plane 2. Setting Up the In-World Plane 3. Remove collision from the in world view 4. Make in-world view accessible in the level blueprint 5. Frontend 1. Wrapper Structure 2. Interactivity 3. CSS and Animations 6. What is next? In this tutorial, we will continue building our game with in-world hologram elements. You can find the rest of the Hologram UI series here. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#showcase-overview] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Showcase Overview In this part, we’ll add an in world screen on top of the box created in the previous tutorial. This screen will display a message indicating that the player can access their inventory when near the box. Additionally, we’ll add smooth transitions to the UI - the screen will close when the player opens their inventory by pressing the `P` key and reopen when the inventory is closed. However, the backend implementation of this functionality will be covered in the next tutorial and in this one we will focus on the UI. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#adding-an-in-world-view] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Adding an in-world view To begin, we’ll add an in-world UI. Since we’ll use multiple in-world views (e.g., the current one and a 3D player inventory menu), it’s more efficient to create a separate Blueprint class for each view rather than adding them directly via the Gameface plugin menu’s `Add In-World UI` option, as described in the documentation [here ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/#4-add-in-world-ui). #### Creating the In-World Plane 1. Locate the `CohtmlPlane` class in `Content/Plugins/Gameface Content` using the Content Browser. **Note: If the `CohtmlPlane` class isn’t visible, first use the `Add In-World UI` option in the plugin to generate the class.** 2. Duplicate the `CohtmlPlane` class and rename it `InWorldPlane` for this tutorial. 3) Drag and drop the `InWorldPlane` Blueprint class into the world and position it on top of the box. #### Setting Up the In-World Plane 1. Open the `InWorldPlane` Blueprint class and access the `Details` panel. 2. Select the `Cohtml` component and change the URL to `coui://uiresources/HologramUI/in-world-screen.html`. 3) Disable game input for the in-world view - in the `Cohtml` component, uncheck the `Receive Input` option. With this setup, the UI from the `in-world-screen.html` page will render on the plane above the box. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#remove-collision-from-the-in-world-view] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Remove collision from the in world view To allow the player to pass through the in-world view, remove its collision: 1. Open the `InWorldPlane` Blueprint class and access the Details panel. 2. Select the `StaticMesh` component. 3. Search for `Collision` and set `Collision Presets` to `No Collision`. After changing this, the player will be able to walk through the plane, as shown below: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#make-in-world-view-accessible-in-the-level-blueprint] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Make in-world view accessible in the level blueprint To program the behavior of the in-world view, we’ll make it accessible within the Level Blueprint: 1. Extend the `InitVariables` method created in the previous tutorial here. 2. Create a new variable in the Level Blueprint: 2.1. Name: `In World Screen` 2.2. Type: `Gameface Component` 3. Set the variable: - Use the `Get All Actors of Class` node with `Actor Class` set to `InWorldPlane`. - Retrieve the first item from the results. - Access the `Cohtml` component of the retrieved actor and assign it to the `In World Screen` variable. With this setup, you can now reference the in-world view in the Level Blueprint to implement functionality such as closing and opening the screen when the player toggles their inventory. This functionality will be detailed in the next tutorial. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#frontend] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Frontend (1/4) For the frontend, we’ll reuse the animated overlay effect from the first part of this tutorial series. This effect creates a noise-like appearance with animated overlay lines. First let’s start with the `HTML` structure for the UI: ```html
    Inventory
    ``` #### Wrapper Structure The main wrapper (`in-world-screen`) contains: 1. An overlay element for the noise effect with two layers: - `overlay-lines` for animated horizontal lines. - `overlay-radial` for a radial gradient that subtly fades the corners. 2. A wrapper element holding the icon and the text (`Inventory`), arranged vertically with a flex column layout. #### Interactivity --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#frontend] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Frontend (2/4) 1. The `cohtml.js` library is included to enable communication between the engine and the UI. 2. The UI listens for two events triggered by the engine: - `playerMenuOpened`: Hides the in-world screen with a transition by adding the `hide-screen` class. - `playerMenuClosed`: Displays the in-world screen again by removing the `hide-screen` class. #### CSS and Animations The noise effect is achieved using CSS animations: 1. `overlay-lines` uses a `linear-gradient` background animated along the x-axis to simulate moving noise lines. 2. `overlay-radial` uses a `radial-gradient` with opacity animations to create a flickering effect. Icon animation is achieved by rotating the icon along the Y-axis between `0°` and `180°`, then back to `0°`. For complete details, check the `in-world-screen-styles.css` file source: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#frontend] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Frontend (3/4) ```css body { width: 100vw; height: 100vh; } .overlay, .overlay-lines, .overlay-radial { position: absolute; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; z-index: 999; } .overlay { mask-image: radial-gradient(circle, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5327380952380952) 65%, rgba(255, 255, 255, 0) 100%); mask-size: 90% 90%; mask-position: center; } .overlay-lines { background-image: linear-gradient(rgba(0, 200, 228, 0.1) 0%, rgba(0, 200, 228, 0.1) 30%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 100%); background-size: 100% 30px; animation: overlay-anim 3s forwards linear infinite; } .overlay-radial { background-image: radial-gradient(circle, rgba(0, 200, 228, 0.2) 0%, rgba(255, 255, 255, 0) 90%, rgba(255, 255, 255, 0) 100%); background-size: 200%; background-position: center; background-repeat: no-repeat; opacity: 0; animation: overlay-radial-anim 3s forwards linear infinite; z-index: 998; } @keyframes overlay-anim { from { background-position: 0% 0%; } to { background-position: 0% -10%; } } @keyframes overlay-radial-anim { 0% { opacity: 0; } 1% { opacity: 1; } 5% { opacity: 0; } 19% { opacity: 0; } 20% { opacity: 1; } 25% { opacity: 0; } 59% { opacity: 0; } 60% { opacity: 1; } 65% { opacity: 0; } 100% { opacity: 0; } } .in-world-screen { background-color: rgb(0, 0, 0, 0); color: white; width: 100vw; height: 100vh; position: absolute; display: flex; align-items: center; justify-content: center; transition: transform 500ms; transform-origin: bottom; } .hide-screen { transform: scaleY(0); } .wrapper { display: flex; flex-direction: column; justify-content: center; align-items: center; } .icon { background-image: url(./assets/iconBackpackSpecial.svg); background-repeat: no-repeat; background-size: contain; height: 35rem; width: 35rem; animation: rotate-icon 2.5s ease-in-out forwards infinite; } @keyframes rotate-icon { 0% { transform: rotateY(0deg); } 25% { transform: rotateY(180deg); } 50% { transform: rotateY(0deg); } } .text { font-size: 7rem; } ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/#frontend] ## In-world hologram UI - Showing an in world screen with a message (Part 2): Frontend (4/4) The icon used for this example is as follows: #### What is next? In the next part of this tutorial, we’ll focus on implementing the backend in Unreal Engine to support the inventory menu. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/] ## In-world hologram UI - In world inventory (Backend) (Part 3) ## In-world hologram UI - In world inventory (Backend) (Part 3) ui tutorials 1/8/2025 Kaloyan Geshev 1. Showcase Overview 2. Creating the plane for the inventory UI 3. Adding in-world view inside the third person character blueprint 4. Adding different cameras for the different views 5. Initialize the relevant variables 6. Making the inventory menu view hidden on start 7. Refocusing the input method 8. Changing the active camera 9. Opening the inventory menu view 10. Closing the inventory menu view 11. What is next? In this tutorial, we’ll create the backend functionality for the player’s inventory menu as part of the In-World Hologram UI series. You can explore the rest of the series here. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#showcase-overview] ## In-world hologram UI - In world inventory (Backend) (Part 3): Showcase Overview This tutorial focuses on setting up the backend for the inventory menu. For this purpose we will do the following things: Here’s what we’ll achieve: 1. Add an in-world view fixed to the player’s camera to display the inventory menu. 2. Change the camera’s position when the inventory menu opens for better focus. 3. Implement functionality to open and close the inventory menu. 4. Hide or reveal the in-world screen from the previous tutorial when toggling the inventory menu. 5. Handle input events for the inventory menu. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#creating-the-plane-for-the-inventory-ui] ## In-world hologram UI - In world inventory (Backend) (Part 3): Creating the plane for the inventory UI To show the inventory of the player we need to setup another view responsible for this. We will use the same approach as we did in the previous tutorial but with slight differences related to the input as we want this view to receive input. We will create a new `CohtmlPlane` class that we will name - `PlayerMenuPlane` following this guide. After we created the class we will set different things for the `StaticMesh` and the `Cohtml` component: 1. `URL` to `coui://uiresources/HologramUI/player-inventory.html` because we will use the `player-inventory.html` page for implementing the UI. 2. `Receive Input` to be checked as we want this plane to receive keyboard and mouse input. 3) `Collision Presets` to `OverlapAllDynamic` in order to we make it possible for Gameface to handle properly the input. If there this option is set to `No collision` for example the `raycast agorythm` that Gameface uses will not transfer in input to that plane. You can read more [here ](https://docs.coherent-labs.com/unreal-gameface/advanced-features/input/#input-on-multiple-hahahugoshortcode-s34-hbhb-components-in-the-3d-world)about how the input is handeled with Gameface in Unreal. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#adding-in-world-view-inside-the-third-person-character-blueprint] ## In-world hologram UI - In world inventory (Backend) (Part 3): Adding in-world view inside the third person character blueprint After we have the plane it is time to add it into the third person blueprint. 1. Open the `BP_ThirdPersonCharacter` blueprint and navigate to the `Viewport` panel. 2. Navigate to the `Components` panel and add new child actor to the `BP_ThirdPersonCharacter/Capsule Component` with the name `MenuPlaneActor`. 3) Select the `MenuPlaneActor` and from the details panel select the `Child Actor Class` to be `PlayerMenuPlane`. Like that you can add in world UI inside a character blueprint class. 4) Drag and drop the `MenuPlaneActor` to the `Viewport` and position it in front of the character. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#adding-different-cameras-for-the-different-views] ## In-world hologram UI - In world inventory (Backend) (Part 3): Adding different cameras for the different views While we are still in the third person character blueprint we will add additional cameras for the player and the inventory. When the player opens or closes the inventory, then the camera view will be toggled between the inventory menu or the character. To do this we will use the same approach as we did with the `MenuPlaneActor`: 1. Add a new `Child Actor` with the name `MenuCamera`, set the `Child Actor Class` to be `CameraActor`, position it to look at the `MenuPlaneActor`. 2) Add a new `Child Actor Class` with the name `FollowCameraActor`, set the `Child Actor Class` to be `CameraActor` and position it to the same position as the `FollowCamera` is. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#initialize-the-relevant-variables] ## In-world hologram UI - In world inventory (Backend) (Part 3): Initialize the relevant variables (1/2) When we are ready with the whole setup in the editor it is time to proceed with the implementation of the game logic in our level blueprint. We are going to start by initializing some new variables that we will use later in our implementation. We will do that in the `InitVariables` method we created earlier and initialize the following new variables: 1. `Player Actor` with type `BP Third Person Character`. We will use it to access the cameras inside the player actor and change the active one when the inventory menu is opened/closed. 2. `Player Menu Actor` with type `Player Menu Plane`. That will enable us to access the plane that we created earlies for showing the inventory in world. We need that for later implementation of changing its `Actor Hidden In Game` property while the game is running so when the inventory is closed to not receive any input events. 3. `Player Menu` with type `Gameface Component`. This is the Gameface view for the inventory. We will need it runtime so we can trigger different events to the UI from the game and vice verca. So the final implementation of our `InitVariables` method is the following: Here we do couple of new things: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#initialize-the-relevant-variables] ## In-world hologram UI - In world inventory (Backend) (Part 3): Initialize the relevant variables (2/2) 1. We are getting all the actors of class `BP Third Person Character` to find and set the `Player Actor` variable. 2. From the `Player Actor` we are getting the `Menu Plane Actor` and then from it we are getting its `Child Actor` that is the `Player Menu Plane`. In order to set it to `Player Menu Actor` variable we need to cast it. 3. From the `Player Menu Actor` we can get the `Cohtml` that is the `Gameface Component` and set it to the `Player Menu` variable. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#making-the-inventory-menu-view-hidden-on-start] ## In-world hologram UI - In world inventory (Backend) (Part 3): Making the inventory menu view hidden on start To make the inventory menu view hidden when the game starts we will use the `Set Actor Hidden in Game` method that accepts the `Player Menu Actor` as a target. We will do this immediately after all the variables are initialized in the level blueprint. We will check the `New Hidden` option that will hide the inventory in world element in the game. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#refocusing-the-input-method] ## In-world hologram UI - In world inventory (Backend) (Part 3): Refocusing the input method To make it possible to focus the inventory menu view when it is opened and enable input events on it we need to create a function for this purpose. The method will accepts the `Input Actor` that we set in the first part of the tutorial series and a boolean variable if the UI should be focused or not. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#changing-the-active-camera] ## In-world hologram UI - In world inventory (Backend) (Part 3): Changing the active camera When the player opens/closes the inventory menu we want to change the active camera to the `MenuCamera` or `FollowCameraActor` that we created earlier in the `BP_ThirdPersonCharacter` blueprint class. For this purpose we will create new method for making this procedure. We will name it `Change Camera To` and will receive a single `String` argument that tells the method which camera is the active one. The values of this argument could be either `Player` or `Menu`. - If it receives `Player` the active camera will be the main following character camera. - If it receives `Menu` the active camera will be the one that focuses the inventory menu. To change the camera we will be using `Set View Target with Blend` method that accepts either the child actor of `FollowCameraActor` or `Menu Camera`. The child actor in fact is a `Camera Actor` as we set it earlier. We will also set 0.5ms for the blend time so we have smoot animation when changing the cameras. Also, here make sure to check the `Lock Outgoing` option so the animation of changing active cameras starts from the last position. This will prevent snapping animation when you open and close the inventory menu really fast and the transition animation has not ended. Calling this method will end up in the following result: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#opening-the-inventory-menu-view] ## In-world hologram UI - In world inventory (Backend) (Part 3): Opening the inventory menu view (1/2) Now lets implement the logic of opening the inventory menu. We need to do the following, when the user opens the inventory menu: 1. We will add an event when the `P` button is pressed in the game and proceed with the other steps. 2. We will check if the tooltip is visible. If the tooltip is not visible (the player is not close to the trigger box) then pressing the `P` button should not continue with the other steps of opening the inventory menu. 3. If the tooltip is visible we can procees further. We will disable the input game mode that means the player won’t be able to move its character and will be able just to interact with the UI. For this purpose we will use the `Set Input Mode UI Only` method that will do this job. Later we will enable again the input game mode when the menu is closed. 4. The next step is to change the visibility of the inventory menu view so the UI is shown in the game. We will do this with the `Set Actor Hidden In Game` accepting the `Player Menu Actor` target. The `New Hidden` argument should not be checked so we make the actor visible. 5. After we changed visibility of the inventory view element we can trigger event to the in world screen we created in the previous tutorial and is on the top of the trigger box so it will become closed with transition animation. We will do that by using the method accessible from the Gameface Plugin - `Trigger JSEvent` that accepts `In World Screen` variable as a target and `Name` of the event - `playerMenuOpened`. This step will result in the following: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#opening-the-inventory-menu-view] ## In-world hologram UI - In world inventory (Backend) (Part 3): Opening the inventory menu view (2/2) 6. To enable the input events on the inventory menu view that is inside the world we will use two methods - `Refocus` that we have created and the `SetViewFocus` that will focus the inventory menu view. You can read more about the `SetViewFocus` in our documentation [here ](https://docs.coherent-labs.com/unreal-gameface/advanced-features/input/#toggling-input-focus-between-the-ui-and-the-game). Both methods will accept `Input Actor` as `Input Actor` argument for the `Refocus` method and `Target` for `SetViewFocus`. Also, you need to check the `Focus` argument of the `Refocus` method because if it is checked the input for the inventory menu will be enabled. `SetViewFocus` also accepts the `Player Menu` Gameface component as `New Focused View`. 7. After we make the inventory view visible and enable input events for it we can hide the tooltip and change the active camera to the menu. We will do this by `Update Tip Visible State` and `Change Camera To` methods. Also we will delay the next step with 0.5 ms so we ensure the camera animation has ended and we can proceed with the open animations of the menu in the UI. So far all the steps will result into this: 8. To start the open animations of the inventory menu UI we will use `Trigger JSEvent` method with target `Player Menu` and event name - `openMenu`. This will notify the UI that the inventory menu has been opened on game command and the UI will start all the opening animation that we will implement in the next tutorial. The final implementation in the level blueprint about opening the inventory menu is the following one: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#closing-the-inventory-menu-view] ## In-world hologram UI - In world inventory (Backend) (Part 3): Closing the inventory menu view (1/3) For closing the menu we will do something similar as opening it but in reverse order. However, the change here is that we will wait for event from the UI in the game for pessing the `P` button as we already disabled the game mode and all the input has been retargeted to the UI. The event that will be triggered from the UI to the game will be called - `closeMenu`. To do that first we need to wait for bindings via `Bind Event to Ready for Bindings` with target the `Player Menu` that is the Gameface Component for the inventory view. When the bindings are ready we can register the event in the game that will be triggered in the UI. This operation we will do after `Event BeginPlay` event and after we waited for binding events for the Gameface HUD. After registering such an event, we need to perform the same actions as we did for opening the menu, but in reverse order: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#closing-the-inventory-menu-view] ## In-world hologram UI - In world inventory (Backend) (Part 3): Closing the inventory menu view (2/3) 1. Add a delay of 1s to wait the close animations of the inventory menu UI to end. 2. Change the camera to the player via `Change Camera To` method with `Camera` argument - `Player`. 3. Set the `Player Menu Actor` to be hidden via `Set Actor Hidden In Game` method and checked `New Hidden` option. 4. Trigger event to the in world message screen that the inventory menu has been closed so the message become visible again. We will do that via calling `Trigger JSEvent` with target `In World Screen` and event name - `playerMenuClosed`. We already implemented the logic in the UI for that event and you can check it here. 5. Refocus the UI via calling `Refocus` with `Focus` argument disabled so the UI should not receive input anymore. 6. Add 0.5ms delay so we make sure that the open animation of the in world message screen ended and we can proceed with showing the tooltip. 7. Update the tooltip state to visible as the player’s character will be in the trigger box boundaries when the inventory menu is closed. This is done by calling `Update Tip Visible State` method with `Visible` argument enabled. 8. Set the input mode to the game only so we give back the control to the character in the game as the player won’t interact anymore with the inventory menu UI. This is done by calling the `Set Input Mode Game Only` method. The final scheme in the level blueprint after the `OnCloseMenu` custom event is the following: And the whole scheme when `Event BeginPlay` is triggered is the following one: With that setup the result should be the following one: #### What is next? --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#closing-the-inventory-menu-view] ## In-world hologram UI - In world inventory (Backend) (Part 3): Closing the inventory menu view (3/3) In the last tutorial we will descibe how to implement the UI of the inventory menu. ## On this page --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/] ## In-world hologram UI - In world inventory (Frontend) (Part 4) ## In-world hologram UI - In world inventory (Frontend) (Part 4) ui tutorials 1/9/2025 Kaloyan Geshev 1. Showcase Overview 2. Getting started - UI layout overview 3. Setting the wrappers 4. Creating the holographic background for menus 5. Weapon preview and stats menu 1. Weapon preview 2. Progress bar initialization 3. Weapon stats 6. Inventory menu 7. Currencies menu 8. Showing menu controls hints 9. Setting up the data model 10. Active item selection 11. Focusing the items 12. Updating the progress bar value 13. Inventory items navigation 14. Enabling entry animations for the menus when the player opens the inventory 15. Closing the menu 16. Animations for the menu 17. Full source code In the final tutorial of this series, we will design the UI for the inventory menu, allowing the player to interact with the items. You can find the rest Hologram UI series here. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#showcase-overview] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Showcase Overview This part will focus on creating the UI for the inventory. We will achieve this by: 1. Using Gameface [data binding ](https://docs.coherent-labs.com/cpp-gameface/integration/ui_scripting/htmldatabinding/)to generate and render the inventory items. 2. Applying `CSS` transforms to create the screens from the image. 3. Utilizing the [progress bar ](https://coherentlabs.github.io/GameUIComponents/en/components/progress-bar/)Gameface component to display weapon stats. 4. Utilizing the [interaction manager ](https://coherentlabs.github.io/GameUIComponents/en/interaction-manager/introduction/)to allow the player to navigate through the items list using the keyboard. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#getting-started---ui-layout-overview] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Getting started - UI layout overview To create the inventory UI, we will divide the screens into three parts: We will create a main wrapper element for all UI parts using display flex in a row direction. Inside this wrapper, we will have two elements that together occupy 100% of the wrapper’s width. The first element will display the weapon stats and preview screen. The second element will use display flex in a column direction and contain two children: 1. The first child will display the inventory items. 2) The second child will display the currencies. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#setting-the-wrappers] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Setting the wrappers (1/3) The `HTML` representation of the above layout is as follows: ```html ``` The main wrapper element is `menu`. Inside it, we have `menu-left` and `menu-right` to split the screen into two parts as described. Inside them, we add `submenu-top` and `submenu-bottom` elements. Since the left menu only shows weapon stats, we omit `submenu-bottom`. The right menu’s `submenu-top` shows the inventory, and `submenu-bottom` shows the currencies. The wrappers will have the following styles: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#setting-the-wrappers] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Setting the wrappers (2/3) ```css .menu { background-color: rgb(0, 0, 0, 0); color: white; width: 100vw; height: 100vh; position: absolute; display: flex; align-items: center; justify-content: center; perspective: 1000px; opacity: 1; } .menu-left, .menu-right { height: 100%; padding: 1rem; } .menu-left { margin-left: 1rem; flex: 1 1 30%; transform: rotateY(20deg) skewY(-3deg) translateY(-1rem); transform-origin: center left; } .menu-right { transform: translateX(-5rem); flex: 1 1 70%; perspective: 1000px; } .submenu-top { transform: scale(0.9) rotateY(-4deg); transform-origin: top right; height: 70%; position: relative; } .submenu-bottom { width: 97.5%; transform: scale(0.9) rotateY(-4deg) rotateX(10deg) skewY(0deg) skewX(-10deg) translateX(5%) translateY(-5%); transform-origin: center; height: 25%; position: relative; } ``` As you can see, we also set the transformations for each screen. To achieve a 3D effect, we use the `perspective` CSS property on the `menu` wrapper. For the other elements, we use different transform properties to achieve the effect shown in the video or images. To simplify the process, we used our [Inspector ](https://docs.coherent-labs.com/cpp-gameface/integration/optional_features/devtools/devtools_cpp/)to transform the wrappers, allowing temporary updates to the UI that are immediately visible in our standalone application called the `Player`. Once satisfied with the result, you can copy the CSS from the `Styles` tab and paste it into your CSS file. --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#setting-the-wrappers] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Setting the wrappers (3/3) **Note: Since the Gameface view in the game created in the [previous](https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-3/#adding-in-world-view-inside-the-third-person-character-blueprint) tutorial also has transformations, it is advisable to check the final result directly in the game. You can open the inspector while the game is running and use the same approach to temporarily edit the elements as with the standalone application.** --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#creating-the-holographic-background-for-menus] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Creating the holographic background for menus (1/2) To achieve the holographic effect for the menu background, follow these steps: - First, create a border as a PNG image for the element. Then, use the `border-image` CSS property to apply a nine-slice scaling technique, ensuring the border’s edges maintain their ratio when the wrapper element is scaled. We will use the following image: - Next, add the noise animation created earlier in the series. To ensure it stays within the border image boundaries and acts as a background, use the `border-radius` CSS property. - Finally, translate and scale the wrapper slightly to create an offset behind the menu wrapper, producing a depth effect. For each submenu, add this element that is positioned absolutely to the menu. Here is an example in our HTML page: ```html ``` --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#creating-the-holographic-background-for-menus] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Creating the holographic background for menus (2/2) Each background is tagged with a specific class to apply different transition animations. For example, the weapon preview background is tagged with the `border-bg-weapon-preview` class. The styles are defined as follows: ```css .overlay, .overlay-lines, .overlay-radial { pointer-events: none; position: absolute; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; z-index: 999; } .overlay-lines { background-image: linear-gradient(rgba(0, 200, 228, 0.1) 0%, rgba(0, 200, 228, 0.1) 30%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 100%); background-size: 100% 0.5rem; animation: overlay-anim 3s forwards linear infinite; } @keyframes overlay-anim { from { background-position: 0% 0%; } to { background-position: 0% -10%; } } .border-radius-lines { border-radius: 4rem; } .border-bg { position: absolute; width: 108%; height: 106%; border-image-source: url(./assets/border.png); border-image-slice: 60; border-image-width: 3.5rem; border-image-outset: 0; border-image-repeat: stretch; z-index: -1; transform: translateX(-2rem) scale(1); top: 1rem; } ``` This will result in a similar effect: --- [SOURCE: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-4/#weapon-preview-and-stats-menu] ## In-world hologram UI - In world inventory (Frontend) (Part 4): Weapon preview and stats menu (1/3) To create the weapon preview menu, we will design a separate submenu wrapper element that displays its children in a column layout. Next, we will create two reusable elements within the submenu wrapper: one for the menu item title and one for the menu item container. This will help us define the layout based on images and videos. #### Weapon preview We will use the following structure in our HTML file: ```html