• Clean up your code: How to create your own C# code style

    While there’s more than one way to format Unity C# code, agreeing on a consistent code style for your project enables your team to develop a clean, readable, and scalable codebase. In this blog, we provide some guidelines and examples you can use to develop and maintain your own code style guide.Please note that these are only recommendations based on those provided by Microsoft. This is your chance to get inspired and decide what works best for your team.Ideally, a Unity project should feel like it’s been developed by a single author, no matter how many developers actually work on it. A style guide can help unify your approach for creating a more cohesive codebase.It’s a good idea to follow industry standards wherever possible and browse through existing style guides as a starting point for creating your own. In partnership with internal and external Unity experts, we released a new e-book, Create a C# style guide: Write cleaner code that scales for inspiration, based on Microsoft’s comprehensive C# style.The Google C# style guide is another great resource for defining guidelines around naming, formatting, and commenting conventions. Again, there is no right or wrong method, but we chose to follow Microsoft standards for our own guide.Our e-book, along with an example C# file, are available for free. Both resources focus on the most common coding conventions you’ll encounter while developing in Unity. These are all, essentially, a subset of the Microsoft Framework Design guidelines, which include an extensive number of best practices beyond what we cover in this post.We recommend customizing the guidelines provided in our style guide to suit your team’s preferences. These preferences should be prioritized over our suggestions and the Microsoft Framework Design guidelines if they’re in conflict.The development of a style guide requires an upfront investment but will pay dividends later. For example, managing a single set of standards can reduce the time developers spend on ramping up if they move onto another project.Of course, consistency is key. If you follow these suggestions and need to modify your style guide in the future, a few find-and-replace operations can quickly migrate your codebase.Concentrate on creating a pragmatic style guide that fits your needs by covering the majority of day-to-day use cases. Don’t overengineer it by attempting to account for every single edge case from the start. The guide will evolve organically over time as your team iterates on it from project to project.Most style guides include basic formatting rules. Meanwhile, specific naming conventions, policy on use of namespaces, and strategies for classes are somewhat abstract areas that can be refined over time.Let’s look at some common formatting and naming conventions you might consider for your style guide.The two common indentation styles in C# are the Allman style, which places the opening curly braces on a new line, and the K&R style, or “one true brace style,” which keeps the opening brace on the same line as the previous header.In an effort to improve readability, we picked the Allman style for our guide, based on the Microsoft Framework Design guidelines:
    Whatever style you choose, ensure that every programmer on your team follows it.A guide should also indicate whether braces from nested multiline statements should be included. While removing braces in the following example won’t throw an error, it can be confusing to read. That’s why our guide recommends applying braces for clarity, even if they are optional.Something as simple as horizontal spacing can enhance your code’s appearance onscreen. While your personal formatting preferences can vary, here are a few recommendations from our style guide to improve overall readability:Add spaces to decrease code density:The extra whitespace can give a sense of visual separation between parts of a lineUse a single space after a comma, between function arguments.Don’t add a space after the parenthesis and function arguments.Don’t use spaces between a function name and parenthesis.Avoid spaces inside brackets.Use a single space before flow control conditions: Add a space between the flow comparison operator and the parentheses.Use a single space before and after comparison operators.Variables typically represent a state, so try to attribute clear and descriptive nouns to their names. You can then prefix booleans with a verbfor variables that must indicate a true or false value. Often they are the answer to a question such as, is the player running? Is the game over? Prefix them with a verb to clarify their meaning. This is often paired with a description or condition, e.g., isPlayerDead, isWalking, hasDamageMultiplier, etc.Since methods perform actions, a good rule of thumb is to start their names with a verb and add context as needed, e.g., GetDirection, FindTarget, and so on, based on the return type. If the method has a bool return type, it can also be framed as a question.Much like boolean variables themselves, prefix methods with a verb if they return a true-false condition. This phrases them in the form of a question, e.g., IsGameOver, HasStartedTurn.Several conventions exist for naming events and event handles. In our style guide, we name the event with a verb phrase,similar to a method. Choose a name that communicates the state change accurately.Use the present or past participle to indicate events “before” or “after.” For instance, specify OpeningDoor for an event before opening a door and DoorOpened for an event afterward.We also recommend that you don’t abbreviate names. While saving a few characters can feel like a productivity gain in the short term, what is obvious to you now might not be in a year’s time to another teammate. Your variable names should reveal their intent and be easy to pronounce. Single letter variables are fine for loops and math expressions, but otherwise, you should avoid abbreviations. Clarity is more important than any time saved from omitting a few vowels.At the same time, use one variable declaration per line; it’s less compact, but also less error prone and enhances readability. Avoid redundant names. If your class is called Player, you don’t need to create member variables called PlayerScore or PlayerTarget. Trim them down to Score or Target.In addition, avoid too many prefixes or special encoding.A practice highlighted in our guide is to prefix private member variables with an underscoreto differentiate them from local variables. Some style guides use prefixes for private member variables, constants, or static variables, so the name reveals more about the variable.However, it’s good practice to prefix interface names with a capital “I” and follow this with an adjective that describes the functionality. You can even prefix the event raising methodwith “On”: The subject that invokes the event usually does so from a method prefixed with “On,” e.g., OnOpeningDoor or OnDoorOpened.Camel case and Pascal case are common standards in use, compared to Snake or Kebab case, or Hungarian notations. Our guide recommends Pascal case for public fields, enums, classes, and methods, and Camel case for private variables, as this is common practice in Unity.There are many additional rules to consider outside of what’s covered here. The example guide and our new e-book, Create a C# style guide: Write cleaner code that scales, provide many more tips for better organization.The concept of clean code aims to make development more scalable by conforming to a set of production standards. A style guide should remove most of the guesswork developers would otherwise have regarding the conventions they should follow. Ultimately, this guide should help your team establish a consensus around your codebase to grow your project into a commercial-scale production.Just how comprehensive your style guide should be depends on your situation. It’s up to your team to decide if they want their guide to set rules for more abstract, intangible concepts. This could include rules for using namespaces, breaking down classes, or implementing directives like the #region directive. While #region can help you collapse and hide sections of code in C# files, making large files more manageable, it’s also an example of something that many developers consider to be code smells or anti-patterns. Therefore, you might want to avoid setting strict standards for these aspects of code styling. Not everything needs to be outlined in the guide – sometimes it’s enough to simply discuss and make decisions as a team.When we talked to the experts who helped create our guide, their main piece of advice was code readability above all else. Here are some pointers on how to achieve that:Use fewer arguments: Arguments can increase the complexity of your method. By reducing their number, you make methods easier to read and test.Avoid excessive overloading: You can generate an endless permutation of method overloads. Select the few that reflect how you’ll call the method, and then implement those. If you do overload a method, prevent confusion by making sure that each method signature has a distinct number of arguments.Avoid side effects: A method only needs to do what its name advertises. Avoid modifying anything outside of its scope. Pass in arguments by value instead of reference when possible. So when sending back results via the out or ref keyword, verify that’s the one thing you intend the method to accomplish. Though side effects are useful for certain tasks, they can lead to unintended consequences. Write a method without side effects to cut down on unexpected behavior.We hope that this blog helps you kick off the development of your own style guide. Learn more from our example C# file and brand new e-book where you can review our suggested rules and customize them to your team’s preferences.The specifics of individual rules are less important than having everyone agree to follow them consistently. When in doubt, rely on your team’s own evolving guide to settle any style disagreements. After all, this is a group effort.
    #clean #your #code #how #create
    Clean up your code: How to create your own C# code style
    While there’s more than one way to format Unity C# code, agreeing on a consistent code style for your project enables your team to develop a clean, readable, and scalable codebase. In this blog, we provide some guidelines and examples you can use to develop and maintain your own code style guide.Please note that these are only recommendations based on those provided by Microsoft. This is your chance to get inspired and decide what works best for your team.Ideally, a Unity project should feel like it’s been developed by a single author, no matter how many developers actually work on it. A style guide can help unify your approach for creating a more cohesive codebase.It’s a good idea to follow industry standards wherever possible and browse through existing style guides as a starting point for creating your own. In partnership with internal and external Unity experts, we released a new e-book, Create a C# style guide: Write cleaner code that scales for inspiration, based on Microsoft’s comprehensive C# style.The Google C# style guide is another great resource for defining guidelines around naming, formatting, and commenting conventions. Again, there is no right or wrong method, but we chose to follow Microsoft standards for our own guide.Our e-book, along with an example C# file, are available for free. Both resources focus on the most common coding conventions you’ll encounter while developing in Unity. These are all, essentially, a subset of the Microsoft Framework Design guidelines, which include an extensive number of best practices beyond what we cover in this post.We recommend customizing the guidelines provided in our style guide to suit your team’s preferences. These preferences should be prioritized over our suggestions and the Microsoft Framework Design guidelines if they’re in conflict.The development of a style guide requires an upfront investment but will pay dividends later. For example, managing a single set of standards can reduce the time developers spend on ramping up if they move onto another project.Of course, consistency is key. If you follow these suggestions and need to modify your style guide in the future, a few find-and-replace operations can quickly migrate your codebase.Concentrate on creating a pragmatic style guide that fits your needs by covering the majority of day-to-day use cases. Don’t overengineer it by attempting to account for every single edge case from the start. The guide will evolve organically over time as your team iterates on it from project to project.Most style guides include basic formatting rules. Meanwhile, specific naming conventions, policy on use of namespaces, and strategies for classes are somewhat abstract areas that can be refined over time.Let’s look at some common formatting and naming conventions you might consider for your style guide.The two common indentation styles in C# are the Allman style, which places the opening curly braces on a new line, and the K&R style, or “one true brace style,” which keeps the opening brace on the same line as the previous header.In an effort to improve readability, we picked the Allman style for our guide, based on the Microsoft Framework Design guidelines: Whatever style you choose, ensure that every programmer on your team follows it.A guide should also indicate whether braces from nested multiline statements should be included. While removing braces in the following example won’t throw an error, it can be confusing to read. That’s why our guide recommends applying braces for clarity, even if they are optional.Something as simple as horizontal spacing can enhance your code’s appearance onscreen. While your personal formatting preferences can vary, here are a few recommendations from our style guide to improve overall readability:Add spaces to decrease code density:The extra whitespace can give a sense of visual separation between parts of a lineUse a single space after a comma, between function arguments.Don’t add a space after the parenthesis and function arguments.Don’t use spaces between a function name and parenthesis.Avoid spaces inside brackets.Use a single space before flow control conditions: Add a space between the flow comparison operator and the parentheses.Use a single space before and after comparison operators.Variables typically represent a state, so try to attribute clear and descriptive nouns to their names. You can then prefix booleans with a verbfor variables that must indicate a true or false value. Often they are the answer to a question such as, is the player running? Is the game over? Prefix them with a verb to clarify their meaning. This is often paired with a description or condition, e.g., isPlayerDead, isWalking, hasDamageMultiplier, etc.Since methods perform actions, a good rule of thumb is to start their names with a verb and add context as needed, e.g., GetDirection, FindTarget, and so on, based on the return type. If the method has a bool return type, it can also be framed as a question.Much like boolean variables themselves, prefix methods with a verb if they return a true-false condition. This phrases them in the form of a question, e.g., IsGameOver, HasStartedTurn.Several conventions exist for naming events and event handles. In our style guide, we name the event with a verb phrase,similar to a method. Choose a name that communicates the state change accurately.Use the present or past participle to indicate events “before” or “after.” For instance, specify OpeningDoor for an event before opening a door and DoorOpened for an event afterward.We also recommend that you don’t abbreviate names. While saving a few characters can feel like a productivity gain in the short term, what is obvious to you now might not be in a year’s time to another teammate. Your variable names should reveal their intent and be easy to pronounce. Single letter variables are fine for loops and math expressions, but otherwise, you should avoid abbreviations. Clarity is more important than any time saved from omitting a few vowels.At the same time, use one variable declaration per line; it’s less compact, but also less error prone and enhances readability. Avoid redundant names. If your class is called Player, you don’t need to create member variables called PlayerScore or PlayerTarget. Trim them down to Score or Target.In addition, avoid too many prefixes or special encoding.A practice highlighted in our guide is to prefix private member variables with an underscoreto differentiate them from local variables. Some style guides use prefixes for private member variables, constants, or static variables, so the name reveals more about the variable.However, it’s good practice to prefix interface names with a capital “I” and follow this with an adjective that describes the functionality. You can even prefix the event raising methodwith “On”: The subject that invokes the event usually does so from a method prefixed with “On,” e.g., OnOpeningDoor or OnDoorOpened.Camel case and Pascal case are common standards in use, compared to Snake or Kebab case, or Hungarian notations. Our guide recommends Pascal case for public fields, enums, classes, and methods, and Camel case for private variables, as this is common practice in Unity.There are many additional rules to consider outside of what’s covered here. The example guide and our new e-book, Create a C# style guide: Write cleaner code that scales, provide many more tips for better organization.The concept of clean code aims to make development more scalable by conforming to a set of production standards. A style guide should remove most of the guesswork developers would otherwise have regarding the conventions they should follow. Ultimately, this guide should help your team establish a consensus around your codebase to grow your project into a commercial-scale production.Just how comprehensive your style guide should be depends on your situation. It’s up to your team to decide if they want their guide to set rules for more abstract, intangible concepts. This could include rules for using namespaces, breaking down classes, or implementing directives like the #region directive. While #region can help you collapse and hide sections of code in C# files, making large files more manageable, it’s also an example of something that many developers consider to be code smells or anti-patterns. Therefore, you might want to avoid setting strict standards for these aspects of code styling. Not everything needs to be outlined in the guide – sometimes it’s enough to simply discuss and make decisions as a team.When we talked to the experts who helped create our guide, their main piece of advice was code readability above all else. Here are some pointers on how to achieve that:Use fewer arguments: Arguments can increase the complexity of your method. By reducing their number, you make methods easier to read and test.Avoid excessive overloading: You can generate an endless permutation of method overloads. Select the few that reflect how you’ll call the method, and then implement those. If you do overload a method, prevent confusion by making sure that each method signature has a distinct number of arguments.Avoid side effects: A method only needs to do what its name advertises. Avoid modifying anything outside of its scope. Pass in arguments by value instead of reference when possible. So when sending back results via the out or ref keyword, verify that’s the one thing you intend the method to accomplish. Though side effects are useful for certain tasks, they can lead to unintended consequences. Write a method without side effects to cut down on unexpected behavior.We hope that this blog helps you kick off the development of your own style guide. Learn more from our example C# file and brand new e-book where you can review our suggested rules and customize them to your team’s preferences.The specifics of individual rules are less important than having everyone agree to follow them consistently. When in doubt, rely on your team’s own evolving guide to settle any style disagreements. After all, this is a group effort. #clean #your #code #how #create
    UNITY.COM
    Clean up your code: How to create your own C# code style
    While there’s more than one way to format Unity C# code, agreeing on a consistent code style for your project enables your team to develop a clean, readable, and scalable codebase. In this blog, we provide some guidelines and examples you can use to develop and maintain your own code style guide.Please note that these are only recommendations based on those provided by Microsoft. This is your chance to get inspired and decide what works best for your team.Ideally, a Unity project should feel like it’s been developed by a single author, no matter how many developers actually work on it. A style guide can help unify your approach for creating a more cohesive codebase.It’s a good idea to follow industry standards wherever possible and browse through existing style guides as a starting point for creating your own. In partnership with internal and external Unity experts, we released a new e-book, Create a C# style guide: Write cleaner code that scales for inspiration, based on Microsoft’s comprehensive C# style.The Google C# style guide is another great resource for defining guidelines around naming, formatting, and commenting conventions. Again, there is no right or wrong method, but we chose to follow Microsoft standards for our own guide.Our e-book, along with an example C# file, are available for free. Both resources focus on the most common coding conventions you’ll encounter while developing in Unity. These are all, essentially, a subset of the Microsoft Framework Design guidelines, which include an extensive number of best practices beyond what we cover in this post.We recommend customizing the guidelines provided in our style guide to suit your team’s preferences. These preferences should be prioritized over our suggestions and the Microsoft Framework Design guidelines if they’re in conflict.The development of a style guide requires an upfront investment but will pay dividends later. For example, managing a single set of standards can reduce the time developers spend on ramping up if they move onto another project.Of course, consistency is key. If you follow these suggestions and need to modify your style guide in the future, a few find-and-replace operations can quickly migrate your codebase.Concentrate on creating a pragmatic style guide that fits your needs by covering the majority of day-to-day use cases. Don’t overengineer it by attempting to account for every single edge case from the start. The guide will evolve organically over time as your team iterates on it from project to project.Most style guides include basic formatting rules. Meanwhile, specific naming conventions, policy on use of namespaces, and strategies for classes are somewhat abstract areas that can be refined over time.Let’s look at some common formatting and naming conventions you might consider for your style guide.The two common indentation styles in C# are the Allman style, which places the opening curly braces on a new line (also known as the BSD style from BSD Unix), and the K&R style, or “one true brace style,” which keeps the opening brace on the same line as the previous header.In an effort to improve readability, we picked the Allman style for our guide, based on the Microsoft Framework Design guidelines: Whatever style you choose, ensure that every programmer on your team follows it.A guide should also indicate whether braces from nested multiline statements should be included. While removing braces in the following example won’t throw an error, it can be confusing to read. That’s why our guide recommends applying braces for clarity, even if they are optional.Something as simple as horizontal spacing can enhance your code’s appearance onscreen. While your personal formatting preferences can vary, here are a few recommendations from our style guide to improve overall readability:Add spaces to decrease code density:The extra whitespace can give a sense of visual separation between parts of a lineUse a single space after a comma, between function arguments.Don’t add a space after the parenthesis and function arguments.Don’t use spaces between a function name and parenthesis.Avoid spaces inside brackets.Use a single space before flow control conditions: Add a space between the flow comparison operator and the parentheses.Use a single space before and after comparison operators.Variables typically represent a state, so try to attribute clear and descriptive nouns to their names. You can then prefix booleans with a verbfor variables that must indicate a true or false value. Often they are the answer to a question such as, is the player running? Is the game over? Prefix them with a verb to clarify their meaning. This is often paired with a description or condition, e.g., isPlayerDead, isWalking, hasDamageMultiplier, etc.Since methods perform actions, a good rule of thumb is to start their names with a verb and add context as needed, e.g., GetDirection, FindTarget, and so on, based on the return type. If the method has a bool return type, it can also be framed as a question.Much like boolean variables themselves, prefix methods with a verb if they return a true-false condition. This phrases them in the form of a question, e.g., IsGameOver, HasStartedTurn.Several conventions exist for naming events and event handles. In our style guide, we name the event with a verb phrase,similar to a method. Choose a name that communicates the state change accurately.Use the present or past participle to indicate events “before” or “after.” For instance, specify OpeningDoor for an event before opening a door and DoorOpened for an event afterward.We also recommend that you don’t abbreviate names. While saving a few characters can feel like a productivity gain in the short term, what is obvious to you now might not be in a year’s time to another teammate. Your variable names should reveal their intent and be easy to pronounce. Single letter variables are fine for loops and math expressions, but otherwise, you should avoid abbreviations. Clarity is more important than any time saved from omitting a few vowels.At the same time, use one variable declaration per line; it’s less compact, but also less error prone and enhances readability. Avoid redundant names. If your class is called Player, you don’t need to create member variables called PlayerScore or PlayerTarget. Trim them down to Score or Target.In addition, avoid too many prefixes or special encoding.A practice highlighted in our guide is to prefix private member variables with an underscore (_) to differentiate them from local variables. Some style guides use prefixes for private member variables (m_), constants (k_), or static variables (s_), so the name reveals more about the variable.However, it’s good practice to prefix interface names with a capital “I” and follow this with an adjective that describes the functionality. You can even prefix the event raising method (in the subject) with “On”: The subject that invokes the event usually does so from a method prefixed with “On,” e.g., OnOpeningDoor or OnDoorOpened.Camel case and Pascal case are common standards in use, compared to Snake or Kebab case, or Hungarian notations. Our guide recommends Pascal case for public fields, enums, classes, and methods, and Camel case for private variables, as this is common practice in Unity.There are many additional rules to consider outside of what’s covered here. The example guide and our new e-book, Create a C# style guide: Write cleaner code that scales, provide many more tips for better organization.The concept of clean code aims to make development more scalable by conforming to a set of production standards. A style guide should remove most of the guesswork developers would otherwise have regarding the conventions they should follow. Ultimately, this guide should help your team establish a consensus around your codebase to grow your project into a commercial-scale production.Just how comprehensive your style guide should be depends on your situation. It’s up to your team to decide if they want their guide to set rules for more abstract, intangible concepts. This could include rules for using namespaces, breaking down classes, or implementing directives like the #region directive (or not). While #region can help you collapse and hide sections of code in C# files, making large files more manageable, it’s also an example of something that many developers consider to be code smells or anti-patterns. Therefore, you might want to avoid setting strict standards for these aspects of code styling. Not everything needs to be outlined in the guide – sometimes it’s enough to simply discuss and make decisions as a team.When we talked to the experts who helped create our guide, their main piece of advice was code readability above all else. Here are some pointers on how to achieve that:Use fewer arguments: Arguments can increase the complexity of your method. By reducing their number, you make methods easier to read and test.Avoid excessive overloading: You can generate an endless permutation of method overloads. Select the few that reflect how you’ll call the method, and then implement those. If you do overload a method, prevent confusion by making sure that each method signature has a distinct number of arguments.Avoid side effects: A method only needs to do what its name advertises. Avoid modifying anything outside of its scope. Pass in arguments by value instead of reference when possible. So when sending back results via the out or ref keyword, verify that’s the one thing you intend the method to accomplish. Though side effects are useful for certain tasks, they can lead to unintended consequences. Write a method without side effects to cut down on unexpected behavior.We hope that this blog helps you kick off the development of your own style guide. Learn more from our example C# file and brand new e-book where you can review our suggested rules and customize them to your team’s preferences.The specifics of individual rules are less important than having everyone agree to follow them consistently. When in doubt, rely on your team’s own evolving guide to settle any style disagreements. After all, this is a group effort.
    0 Comentários 0 Compartilhamentos
  • Itoosoft releases RailClone 7

    html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ";

    Itoosoft has released RailClone 7, the latest version of its 3ds Max parametric modelling plugin.The update introduces a new set of Spline Operators for manipulating splines in a wide range of ways, comprising 10 new nodes with 19 separate features.
    Users of the paid Pro edition get RailClone Systems, a new set of readymade procedural assets for generating common architectural structures like windows, curtain walls, and cabling.
    A popular parametric modelling tool for architectural visualisation work

    First released in 2010, RailClone makes it possible to generate complex 3D models by defining procedural construction rules using a node-based workflow.Users can create complex 3D models by repeating simple base meshes, or ‘Segments’, along splines, using Generators to arrange them into arrays, and Operators to control their properties.
    Although the workflow applies to visual effects or motion graphics, the plugin is most commonly used to generate buildings and street furniture for architectural visualisation projects.
    It is compatible with a range of third-party renderers, including Arnold, Corona, FStorm, OctaneRender, Redshift and V-Ray.

    RailClone 7: new multi-purpose Spline Operators

    RailClone 7 adds a new category of Spline Operators to the software’s graph editor.The 10 new nodes include Basic Ops, a new ‘multi-tool’ for performing common operations on splines, like transforming, breaking, combining, flattening or chamfering splines.
    A new Boolean node performs standard Boolean operations on regions bounded by splines.
    Other new nodes include Offset, for creating repeating clones of splines; Catenary, for creating the catenary curves generated by cables hanging under their own weight; and Conform, for projecting splines onto terrain.
    The images in Itoosoft’s blog post show potential use cases ranging from creating road networks to structures like wiring, railings and gantries.
    In addition, a new Draw Splines mode makes it possible to preview the result of spline operations directly in the viewport.
    New version-independent portable file format, and updates to point clouds

    Other new features include the Itoosoft Portable file format, making it possible to save RailClone objects in a file format independent of the version of 3ds Max used to create them.The point cloud display mode has been updated, with each RailClone object now using a fixed number of points, rather than point density being dependent on distance from the camera.
    According to Itoosoft, the new mode is optimized for modern GPUs and versions of 3ds Max.
    There are also a number of smaller workflow and feature updates, especially to macros, array generation, and handling of V-Ray Proxies when rendering with V-Ray GPU or Vantage.

    Pro edition: new RailClone Systems procedural assets

    Users of the paid Pro edition also get RailClone Systems, a new set of customizable readymade procedural assets for creating common architectural elements like windows, suspended ceilings, curtain walls, boardwalks, and cabling.You can see the new assets in the online preview of RailClone’s asset library.
    Price and system requirements

    RailClone 7.0 is available for 3ds Max 2022+. Feature support varies between the compatible renderers. New licences start at including one year’s maintenance. There is also a free, feature-limited Lite edition of the plugin.
    Read an overview of the new features in RailClone 7 on iToo Software’s blog
    Read a full list of new features in RailClone in the online release notes.
    Visit the RailClone product websiteHave your say on this story by following CG Channel on Facebook, Instagram and X. As well as being able to comment on stories, followers of our social media accounts can see videos we don’t post on the site itself, including making-ofs for the latest VFX movies, animations, games cinematics and motion graphics projects.
    #itoosoft #releases #railclone
    Itoosoft releases RailClone 7
    html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "; Itoosoft has released RailClone 7, the latest version of its 3ds Max parametric modelling plugin.The update introduces a new set of Spline Operators for manipulating splines in a wide range of ways, comprising 10 new nodes with 19 separate features. Users of the paid Pro edition get RailClone Systems, a new set of readymade procedural assets for generating common architectural structures like windows, curtain walls, and cabling. A popular parametric modelling tool for architectural visualisation work First released in 2010, RailClone makes it possible to generate complex 3D models by defining procedural construction rules using a node-based workflow.Users can create complex 3D models by repeating simple base meshes, or ‘Segments’, along splines, using Generators to arrange them into arrays, and Operators to control their properties. Although the workflow applies to visual effects or motion graphics, the plugin is most commonly used to generate buildings and street furniture for architectural visualisation projects. It is compatible with a range of third-party renderers, including Arnold, Corona, FStorm, OctaneRender, Redshift and V-Ray. RailClone 7: new multi-purpose Spline Operators RailClone 7 adds a new category of Spline Operators to the software’s graph editor.The 10 new nodes include Basic Ops, a new ‘multi-tool’ for performing common operations on splines, like transforming, breaking, combining, flattening or chamfering splines. A new Boolean node performs standard Boolean operations on regions bounded by splines. Other new nodes include Offset, for creating repeating clones of splines; Catenary, for creating the catenary curves generated by cables hanging under their own weight; and Conform, for projecting splines onto terrain. The images in Itoosoft’s blog post show potential use cases ranging from creating road networks to structures like wiring, railings and gantries. In addition, a new Draw Splines mode makes it possible to preview the result of spline operations directly in the viewport. New version-independent portable file format, and updates to point clouds Other new features include the Itoosoft Portable file format, making it possible to save RailClone objects in a file format independent of the version of 3ds Max used to create them.The point cloud display mode has been updated, with each RailClone object now using a fixed number of points, rather than point density being dependent on distance from the camera. According to Itoosoft, the new mode is optimized for modern GPUs and versions of 3ds Max. There are also a number of smaller workflow and feature updates, especially to macros, array generation, and handling of V-Ray Proxies when rendering with V-Ray GPU or Vantage. Pro edition: new RailClone Systems procedural assets Users of the paid Pro edition also get RailClone Systems, a new set of customizable readymade procedural assets for creating common architectural elements like windows, suspended ceilings, curtain walls, boardwalks, and cabling.You can see the new assets in the online preview of RailClone’s asset library. Price and system requirements RailClone 7.0 is available for 3ds Max 2022+. Feature support varies between the compatible renderers. New licences start at including one year’s maintenance. There is also a free, feature-limited Lite edition of the plugin. Read an overview of the new features in RailClone 7 on iToo Software’s blog Read a full list of new features in RailClone in the online release notes. Visit the RailClone product websiteHave your say on this story by following CG Channel on Facebook, Instagram and X. As well as being able to comment on stories, followers of our social media accounts can see videos we don’t post on the site itself, including making-ofs for the latest VFX movies, animations, games cinematics and motion graphics projects. #itoosoft #releases #railclone
    WWW.CGCHANNEL.COM
    Itoosoft releases RailClone 7
    html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd" Itoosoft has released RailClone 7, the latest version of its 3ds Max parametric modelling plugin.The update introduces a new set of Spline Operators for manipulating splines in a wide range of ways, comprising 10 new nodes with 19 separate features. Users of the paid Pro edition get RailClone Systems, a new set of readymade procedural assets for generating common architectural structures like windows, curtain walls, and cabling. A popular parametric modelling tool for architectural visualisation work First released in 2010, RailClone makes it possible to generate complex 3D models by defining procedural construction rules using a node-based workflow.Users can create complex 3D models by repeating simple base meshes, or ‘Segments’, along splines, using Generators to arrange them into arrays, and Operators to control their properties. Although the workflow applies to visual effects or motion graphics, the plugin is most commonly used to generate buildings and street furniture for architectural visualisation projects. It is compatible with a range of third-party renderers, including Arnold, Corona, FStorm, OctaneRender, Redshift and V-Ray. RailClone 7: new multi-purpose Spline Operators RailClone 7 adds a new category of Spline Operators to the software’s graph editor.The 10 new nodes include Basic Ops, a new ‘multi-tool’ for performing common operations on splines, like transforming, breaking, combining, flattening or chamfering splines. A new Boolean node performs standard Boolean operations on regions bounded by splines. Other new nodes include Offset, for creating repeating clones of splines; Catenary, for creating the catenary curves generated by cables hanging under their own weight; and Conform, for projecting splines onto terrain. The images in Itoosoft’s blog post show potential use cases ranging from creating road networks to structures like wiring, railings and gantries. In addition, a new Draw Splines mode makes it possible to preview the result of spline operations directly in the viewport. New version-independent portable file format, and updates to point clouds Other new features include the Itoosoft Portable file format, making it possible to save RailClone objects in a file format independent of the version of 3ds Max used to create them.The point cloud display mode has been updated, with each RailClone object now using a fixed number of points, rather than point density being dependent on distance from the camera. According to Itoosoft, the new mode is optimized for modern GPUs and versions of 3ds Max. There are also a number of smaller workflow and feature updates, especially to macros, array generation, and handling of V-Ray Proxies when rendering with V-Ray GPU or Vantage. Pro edition: new RailClone Systems procedural assets Users of the paid Pro edition also get RailClone Systems, a new set of customizable readymade procedural assets for creating common architectural elements like windows, suspended ceilings, curtain walls, boardwalks, and cabling.You can see the new assets in the online preview of RailClone’s asset library. Price and system requirements RailClone 7.0 is available for 3ds Max 2022+. Feature support varies between the compatible renderers. New licences start at $275, including one year’s maintenance. There is also a free, feature-limited Lite edition of the plugin. Read an overview of the new features in RailClone 7 on iToo Software’s blog Read a full list of new features in RailClone in the online release notes. Visit the RailClone product website (Includes a download link for RailClone Lite at the foot of the page) Have your say on this story by following CG Channel on Facebook, Instagram and X (formerly Twitter). As well as being able to comment on stories, followers of our social media accounts can see videos we don’t post on the site itself, including making-ofs for the latest VFX movies, animations, games cinematics and motion graphics projects.
    0 Comentários 0 Compartilhamentos
  • 6 ways ScriptableObjects can benefit your team and your code

    We’re happy to announce that we’ve launched a new technical e-book, Create modular game architecture in Unity with ScriptableObjects, which provides best practices from professional developers for deploying ScriptableObjects in production.Along with the e-book, you can download a demo project from GitHub inspired by classic ball and paddle arcade game mechanics. The demo shows how ScriptableObjects can help you create components that are testable and scalable, while also being designer-friendly. Although a game like this could be built with far fewer lines of code, this demo shows ScriptableObjects in action.This post explains the benefits of ScriptableObjects, but doesn’t cover the basics or general coding in Unity. If you’re new to programming in Unity, head over to Unity Learn, which offers helpful introductory tutorials. The first chapter in the e-book also offers a solid primer.Let’s look at six ways you can benefit from using ScriptableObjects in your projects. Want to know more? All of these examples are explored further in the e-book and demo project.Although many of the techniques shared here can also be achieved using C# classes, one of the main benefits of ScriptableObjects is the accessibility to artists and designers. They can use ScriptableObjects to configure and apply game logic in a project without having to edit the code.The Editor makes it convenient to view and edit ScriptableObjects, enabling designers to set up gameplay data without heavy support from the developer team. This also applies to game logic, such as applying behavior to an NPC by adding a ScriptableObject.Storing data and logic on a single MonoBehaviour can result in time-consuming merge conflicts if two people change different parts of the same Prefab or scene. By breaking up shared data into smaller files and assets with ScriptableObjects, designers can build gameplay in parallel with developers, instead of having to wait for the latter to finish setting up the gameplay in code before testing it.Issues can arise when colleagues with different roles access the game code and assets at the same time. With ScriptableObjects, the programmer can control what part of the project is editable in the Editor. Additionally, using ScriptableObjects to organize your code leads naturally to a codebase that’s more modular and efficient to test.Christo Nobbs, a senior technical game designer who specializes in systems game design and Unity, contributed to The Unity game designer playbook, and is the main author of a blog post series on designing game systems in Unity. His posts, “Systems that create ecosystems: Emergent game design” and “Unpredictably fun: The value of randomization in game design” provide interesting examples of how designers can use ScriptableObjects.Modularity is a general software principle which can be implemented in C# without using ScriptableObjects. But, as mentioned above, ScriptableObjects help promote clean coding practices by separating data from logic, which is a first step toward modular game code. This separation means it’s easier to make changes without causing unintended side effects, and improves testability.ScriptableObjects excel at storing static data, making them handy for configuring static gameplay values like items or NPC stats, character dialogue, and much more. Because ScriptableObjects are saved as an asset, they persist outside of game mode, making it possible to use them for loading in a static configuration that dynamically changes at runtime.While changes to ScriptableObject data do persist in the Editor, it’s important to note that they are not designed for saving game data. In that case, it’s better to use a serialization system, such as JSON, XML, or a binary solution if performance is critical.MonoBehaviours carry extra overhead since they require a GameObject – and by default a Transform – to act as a host. This means you need to create a lot of unused data before storing a single value. A ScriptableObject slims down this memory footprint and drops the GameObject and Transform. It also stores data at the project level, which is helpful if you need to access the same data from multiple scenes.It’s common to have many GameObjects which rely on duplicate data that does not need to change at runtime. Rather than having this duplicate local data on each GameObject, you can funnel it into a ScriptableObject. Each of the objects stores a reference to the shared data asset, rather than copying the data itself. This can provide significant performance improvements in projects with thousands of objects.In software design, this is an optimization known as the flyweight pattern. Restructuring your code in this way using ScriptableObjects avoids copying values and reduces your memory footprint. Check out our e-book, Level up your code with game programming patterns to learn more about using design patterns in Unity.A good example of how ScriptableObjects can simplify your code is to use them as enums for comparison operations. The ScriptableObject can represent a category or item type, such as a special damage effect – cold, heat, electrical, magic, etc.If your application requires an inventory system to equip gameplay items, ScriptableObjects can represent item types or weapon slots. The fields in the Inspector then function as a drag-and-drop interface for setting them up.Using ScriptableObjects as enums becomes more interesting when you want to extend them and add more data. Unlike normal enums, ScriptableObjects can have extra fields and methods. There’s no need to have a separate lookup table or correlate with a new array of data.While traditional enums have a fixed set of values, ScriptableObject enums can be created and modified at runtime, allowing you to add or remove values as needed.If you have a long list of enum values without explicit numbering, inserting or removing an enum can change their order. This reordering can introduce subtle bugs or unintended behavior. ScriptableObject-based enums don’t have these issues. You can delete or add to your project without having to change the code every time.Suppose you want to make an item equippable in an RPG. You could append an extra boolean field to the ScriptableObject to do that. Are certain characters not allowed to hold certain items? Are some items magical or do they have special abilities? ScriptableObject-based enums can do that.Because you can create methods on a ScriptableObject, they are as useful for containing logic or actions as they are for holding data. Moving logic from your MonoBehaviour into a ScriptableObject enables you to use the latter as a delegate object, making the behavior more modular.If you need to perform specific tasks, you can encapsulate their algorithms into their own objects. The original Gang of Four refers to this general design as the strategy pattern. The example below shows how to make the strategy pattern more useful by using an abstract class to implement EnemyAI. The result is several derived ScriptableObjects with different behavior, which then becomes a pluggable behavior since each asset is interchangeable. You just drag and drop the ScriptableObject of choice into the MonoBehaviour.For a detailed example showing how to use ScriptableObjects to drive behavior, watch the video series Pluggable AI with ScriptableObjects. These sessions demonstrate a finite state machine-based AI system that can be configured using ScriptableObjects for states, actions, and transitions between those states.A common challenge in larger projects is when multiple GameObjects need to share data or states by avoiding direct references between these objects. Managing these dependencies at scale can require significant effort and is often a source of bugs. Many developers use singletons – one global instance of a class that survives scene loading. However, singletons introduce global states and make unit testing difficult. If you’re working with a Prefab that references a singleton, you’ll end up importing all of its dependencies just to test an isolated function. This makes your code less modular and efficient to debug.One solution is to use ScriptableObject-based events to help your GameObjects communicate. In this case, you are using ScriptableObjects to implement a form of the observer design pattern, where a subject broadcasts a message to one or more loosely decoupled observers. Each observing object can react independently from the subject but is unaware of the other observers. The subject can also be referred to as the “publisher” or “broadcaster” and the observers as “subscribers” or “listeners.”You can implement the observer pattern with MonoBehaviours or C# objects. While this is already common practice in Unity development, a script-only approach means your designers will rely on the programming team for every event needed during gameplay.At first glance, it appears that you’ve added a layer of overhead to the observer pattern, but this structure offers some advantages. Since ScriptableObjects are assets, they are accessible to all objects in your hierarchy and don’t disappear on scene loading.Easy, persistent access to certain resources is why many developers use singletons. ScriptableObjects can often provide the same benefits without introducing as many unnecessary dependencies.In ScriptableObject-based events, any object can serve as publisher, and any object can serve as a subscriber. The ScriptableObject sits in the middle and helps relay the signal, acting like a centralized intermediary between the two.One way to think about this is as an “event channel.” Imagine the ScriptableObject as a radio tower that has any number of objects listening for its signals. An interested MonoBehaviour can subscribe to the event channel and respond when something happens.The demo shows how the observer pattern helps you set up game events for UI, sounds, and scoring.At runtime, you’ll often need to track a list of GameObjects or components in your scene. For example, a list of enemies is something you’d need to frequently access, but it’s also a dynamic list that changes as more enemies are spawned or defeated. The singleton offers easy global access, but it has several drawbacks. Instead of using a singleton, consider storing data on a ScriptableObject as a “Runtime Set.” The ScriptableObject instance appears at the project level, which means it can store data that’s available to any object from any scene, offering similar global access. Since the data is located on an asset, its public list of items is accessible at any time.In this use case, you get a specialized data container that maintains a public collection of elements but also provides basic methods to add to and remove from the collection. This can reduce the need for singletons and improve testability and modularity.Reading data directly from a ScriptableObject is also more optimal than searching the Scene Hierarchy with a find operation like Object.FindObjectOfType or GameObject.FindWithTag. Depending on your use case and the size of your hierarchy, these are relatively expensive methods that can be inefficient for per-frame updates.There are several ScriptableObjects frameworks which offer more use cases than these six scenarios. Some teams decide to use ScriptableObjects extensively, while others limit their use to loading in static data and separating logic from data. Ultimately, the needs of your project will determine how you use them.Create modular game architecture in Unity with ScriptableObjects is the third guide in our series for intermediate to advanced Unity programmers. Each guide, authored by experienced programmers, provides best practices for topics that are important to development teams.Create a C# style guide: Write cleaner code that scales assists you with developing a style guide to help unify your approach to creating a more cohesive codebase.Level up your code with game programming patternshighlights best practices for using the SOLID principles and common programming patterns to create scalable game code architecture in your Unity project.We created this series to provide actionable tips and inspiration to our experienced creators, but they aren’t rule books. There are many ways to structure your Unity project and what might seem like a natural fit for one application may not be for another. Evaluate the advantages and disadvantages of each recommendation, tip, and pattern with your colleagues before deploying it.Find more advanced guides and articles on the Unity best practices hub.
    #ways #scriptableobjects #can #benefit #your
    6 ways ScriptableObjects can benefit your team and your code
    We’re happy to announce that we’ve launched a new technical e-book, Create modular game architecture in Unity with ScriptableObjects, which provides best practices from professional developers for deploying ScriptableObjects in production.Along with the e-book, you can download a demo project from GitHub inspired by classic ball and paddle arcade game mechanics. The demo shows how ScriptableObjects can help you create components that are testable and scalable, while also being designer-friendly. Although a game like this could be built with far fewer lines of code, this demo shows ScriptableObjects in action.This post explains the benefits of ScriptableObjects, but doesn’t cover the basics or general coding in Unity. If you’re new to programming in Unity, head over to Unity Learn, which offers helpful introductory tutorials. The first chapter in the e-book also offers a solid primer.Let’s look at six ways you can benefit from using ScriptableObjects in your projects. Want to know more? All of these examples are explored further in the e-book and demo project.Although many of the techniques shared here can also be achieved using C# classes, one of the main benefits of ScriptableObjects is the accessibility to artists and designers. They can use ScriptableObjects to configure and apply game logic in a project without having to edit the code.The Editor makes it convenient to view and edit ScriptableObjects, enabling designers to set up gameplay data without heavy support from the developer team. This also applies to game logic, such as applying behavior to an NPC by adding a ScriptableObject.Storing data and logic on a single MonoBehaviour can result in time-consuming merge conflicts if two people change different parts of the same Prefab or scene. By breaking up shared data into smaller files and assets with ScriptableObjects, designers can build gameplay in parallel with developers, instead of having to wait for the latter to finish setting up the gameplay in code before testing it.Issues can arise when colleagues with different roles access the game code and assets at the same time. With ScriptableObjects, the programmer can control what part of the project is editable in the Editor. Additionally, using ScriptableObjects to organize your code leads naturally to a codebase that’s more modular and efficient to test.Christo Nobbs, a senior technical game designer who specializes in systems game design and Unity, contributed to The Unity game designer playbook, and is the main author of a blog post series on designing game systems in Unity. His posts, “Systems that create ecosystems: Emergent game design” and “Unpredictably fun: The value of randomization in game design” provide interesting examples of how designers can use ScriptableObjects.Modularity is a general software principle which can be implemented in C# without using ScriptableObjects. But, as mentioned above, ScriptableObjects help promote clean coding practices by separating data from logic, which is a first step toward modular game code. This separation means it’s easier to make changes without causing unintended side effects, and improves testability.ScriptableObjects excel at storing static data, making them handy for configuring static gameplay values like items or NPC stats, character dialogue, and much more. Because ScriptableObjects are saved as an asset, they persist outside of game mode, making it possible to use them for loading in a static configuration that dynamically changes at runtime.While changes to ScriptableObject data do persist in the Editor, it’s important to note that they are not designed for saving game data. In that case, it’s better to use a serialization system, such as JSON, XML, or a binary solution if performance is critical.MonoBehaviours carry extra overhead since they require a GameObject – and by default a Transform – to act as a host. This means you need to create a lot of unused data before storing a single value. A ScriptableObject slims down this memory footprint and drops the GameObject and Transform. It also stores data at the project level, which is helpful if you need to access the same data from multiple scenes.It’s common to have many GameObjects which rely on duplicate data that does not need to change at runtime. Rather than having this duplicate local data on each GameObject, you can funnel it into a ScriptableObject. Each of the objects stores a reference to the shared data asset, rather than copying the data itself. This can provide significant performance improvements in projects with thousands of objects.In software design, this is an optimization known as the flyweight pattern. Restructuring your code in this way using ScriptableObjects avoids copying values and reduces your memory footprint. Check out our e-book, Level up your code with game programming patterns to learn more about using design patterns in Unity.A good example of how ScriptableObjects can simplify your code is to use them as enums for comparison operations. The ScriptableObject can represent a category or item type, such as a special damage effect – cold, heat, electrical, magic, etc.If your application requires an inventory system to equip gameplay items, ScriptableObjects can represent item types or weapon slots. The fields in the Inspector then function as a drag-and-drop interface for setting them up.Using ScriptableObjects as enums becomes more interesting when you want to extend them and add more data. Unlike normal enums, ScriptableObjects can have extra fields and methods. There’s no need to have a separate lookup table or correlate with a new array of data.While traditional enums have a fixed set of values, ScriptableObject enums can be created and modified at runtime, allowing you to add or remove values as needed.If you have a long list of enum values without explicit numbering, inserting or removing an enum can change their order. This reordering can introduce subtle bugs or unintended behavior. ScriptableObject-based enums don’t have these issues. You can delete or add to your project without having to change the code every time.Suppose you want to make an item equippable in an RPG. You could append an extra boolean field to the ScriptableObject to do that. Are certain characters not allowed to hold certain items? Are some items magical or do they have special abilities? ScriptableObject-based enums can do that.Because you can create methods on a ScriptableObject, they are as useful for containing logic or actions as they are for holding data. Moving logic from your MonoBehaviour into a ScriptableObject enables you to use the latter as a delegate object, making the behavior more modular.If you need to perform specific tasks, you can encapsulate their algorithms into their own objects. The original Gang of Four refers to this general design as the strategy pattern. The example below shows how to make the strategy pattern more useful by using an abstract class to implement EnemyAI. The result is several derived ScriptableObjects with different behavior, which then becomes a pluggable behavior since each asset is interchangeable. You just drag and drop the ScriptableObject of choice into the MonoBehaviour.For a detailed example showing how to use ScriptableObjects to drive behavior, watch the video series Pluggable AI with ScriptableObjects. These sessions demonstrate a finite state machine-based AI system that can be configured using ScriptableObjects for states, actions, and transitions between those states.A common challenge in larger projects is when multiple GameObjects need to share data or states by avoiding direct references between these objects. Managing these dependencies at scale can require significant effort and is often a source of bugs. Many developers use singletons – one global instance of a class that survives scene loading. However, singletons introduce global states and make unit testing difficult. If you’re working with a Prefab that references a singleton, you’ll end up importing all of its dependencies just to test an isolated function. This makes your code less modular and efficient to debug.One solution is to use ScriptableObject-based events to help your GameObjects communicate. In this case, you are using ScriptableObjects to implement a form of the observer design pattern, where a subject broadcasts a message to one or more loosely decoupled observers. Each observing object can react independently from the subject but is unaware of the other observers. The subject can also be referred to as the “publisher” or “broadcaster” and the observers as “subscribers” or “listeners.”You can implement the observer pattern with MonoBehaviours or C# objects. While this is already common practice in Unity development, a script-only approach means your designers will rely on the programming team for every event needed during gameplay.At first glance, it appears that you’ve added a layer of overhead to the observer pattern, but this structure offers some advantages. Since ScriptableObjects are assets, they are accessible to all objects in your hierarchy and don’t disappear on scene loading.Easy, persistent access to certain resources is why many developers use singletons. ScriptableObjects can often provide the same benefits without introducing as many unnecessary dependencies.In ScriptableObject-based events, any object can serve as publisher, and any object can serve as a subscriber. The ScriptableObject sits in the middle and helps relay the signal, acting like a centralized intermediary between the two.One way to think about this is as an “event channel.” Imagine the ScriptableObject as a radio tower that has any number of objects listening for its signals. An interested MonoBehaviour can subscribe to the event channel and respond when something happens.The demo shows how the observer pattern helps you set up game events for UI, sounds, and scoring.At runtime, you’ll often need to track a list of GameObjects or components in your scene. For example, a list of enemies is something you’d need to frequently access, but it’s also a dynamic list that changes as more enemies are spawned or defeated. The singleton offers easy global access, but it has several drawbacks. Instead of using a singleton, consider storing data on a ScriptableObject as a “Runtime Set.” The ScriptableObject instance appears at the project level, which means it can store data that’s available to any object from any scene, offering similar global access. Since the data is located on an asset, its public list of items is accessible at any time.In this use case, you get a specialized data container that maintains a public collection of elements but also provides basic methods to add to and remove from the collection. This can reduce the need for singletons and improve testability and modularity.Reading data directly from a ScriptableObject is also more optimal than searching the Scene Hierarchy with a find operation like Object.FindObjectOfType or GameObject.FindWithTag. Depending on your use case and the size of your hierarchy, these are relatively expensive methods that can be inefficient for per-frame updates.There are several ScriptableObjects frameworks which offer more use cases than these six scenarios. Some teams decide to use ScriptableObjects extensively, while others limit their use to loading in static data and separating logic from data. Ultimately, the needs of your project will determine how you use them.Create modular game architecture in Unity with ScriptableObjects is the third guide in our series for intermediate to advanced Unity programmers. Each guide, authored by experienced programmers, provides best practices for topics that are important to development teams.Create a C# style guide: Write cleaner code that scales assists you with developing a style guide to help unify your approach to creating a more cohesive codebase.Level up your code with game programming patternshighlights best practices for using the SOLID principles and common programming patterns to create scalable game code architecture in your Unity project.We created this series to provide actionable tips and inspiration to our experienced creators, but they aren’t rule books. There are many ways to structure your Unity project and what might seem like a natural fit for one application may not be for another. Evaluate the advantages and disadvantages of each recommendation, tip, and pattern with your colleagues before deploying it.Find more advanced guides and articles on the Unity best practices hub. #ways #scriptableobjects #can #benefit #your
    UNITY.COM
    6 ways ScriptableObjects can benefit your team and your code
    We’re happy to announce that we’ve launched a new technical e-book, Create modular game architecture in Unity with ScriptableObjects, which provides best practices from professional developers for deploying ScriptableObjects in production.Along with the e-book, you can download a demo project from GitHub inspired by classic ball and paddle arcade game mechanics. The demo shows how ScriptableObjects can help you create components that are testable and scalable, while also being designer-friendly. Although a game like this could be built with far fewer lines of code, this demo shows ScriptableObjects in action.This post explains the benefits of ScriptableObjects, but doesn’t cover the basics or general coding in Unity. If you’re new to programming in Unity, head over to Unity Learn, which offers helpful introductory tutorials. The first chapter in the e-book also offers a solid primer.Let’s look at six ways you can benefit from using ScriptableObjects in your projects. Want to know more? All of these examples are explored further in the e-book and demo project.Although many of the techniques shared here can also be achieved using C# classes, one of the main benefits of ScriptableObjects is the accessibility to artists and designers. They can use ScriptableObjects to configure and apply game logic in a project without having to edit the code.The Editor makes it convenient to view and edit ScriptableObjects, enabling designers to set up gameplay data without heavy support from the developer team. This also applies to game logic, such as applying behavior to an NPC by adding a ScriptableObject (explained in the patterns below).Storing data and logic on a single MonoBehaviour can result in time-consuming merge conflicts if two people change different parts of the same Prefab or scene. By breaking up shared data into smaller files and assets with ScriptableObjects, designers can build gameplay in parallel with developers, instead of having to wait for the latter to finish setting up the gameplay in code before testing it.Issues can arise when colleagues with different roles access the game code and assets at the same time. With ScriptableObjects, the programmer can control what part of the project is editable in the Editor. Additionally, using ScriptableObjects to organize your code leads naturally to a codebase that’s more modular and efficient to test.Christo Nobbs, a senior technical game designer who specializes in systems game design and Unity (C#), contributed to The Unity game designer playbook, and is the main author of a blog post series on designing game systems in Unity. His posts, “Systems that create ecosystems: Emergent game design” and “Unpredictably fun: The value of randomization in game design” provide interesting examples of how designers can use ScriptableObjects.Modularity is a general software principle which can be implemented in C# without using ScriptableObjects. But, as mentioned above, ScriptableObjects help promote clean coding practices by separating data from logic, which is a first step toward modular game code. This separation means it’s easier to make changes without causing unintended side effects, and improves testability.ScriptableObjects excel at storing static data, making them handy for configuring static gameplay values like items or NPC stats, character dialogue, and much more. Because ScriptableObjects are saved as an asset, they persist outside of game mode, making it possible to use them for loading in a static configuration that dynamically changes at runtime.While changes to ScriptableObject data do persist in the Editor, it’s important to note that they are not designed for saving game data. In that case, it’s better to use a serialization system, such as JSON, XML, or a binary solution if performance is critical.MonoBehaviours carry extra overhead since they require a GameObject – and by default a Transform – to act as a host. This means you need to create a lot of unused data before storing a single value. A ScriptableObject slims down this memory footprint and drops the GameObject and Transform. It also stores data at the project level, which is helpful if you need to access the same data from multiple scenes.It’s common to have many GameObjects which rely on duplicate data that does not need to change at runtime. Rather than having this duplicate local data on each GameObject, you can funnel it into a ScriptableObject. Each of the objects stores a reference to the shared data asset, rather than copying the data itself. This can provide significant performance improvements in projects with thousands of objects.In software design, this is an optimization known as the flyweight pattern. Restructuring your code in this way using ScriptableObjects avoids copying values and reduces your memory footprint. Check out our e-book, Level up your code with game programming patterns to learn more about using design patterns in Unity.A good example of how ScriptableObjects can simplify your code is to use them as enums for comparison operations. The ScriptableObject can represent a category or item type, such as a special damage effect – cold, heat, electrical, magic, etc.If your application requires an inventory system to equip gameplay items, ScriptableObjects can represent item types or weapon slots. The fields in the Inspector then function as a drag-and-drop interface for setting them up.Using ScriptableObjects as enums becomes more interesting when you want to extend them and add more data. Unlike normal enums, ScriptableObjects can have extra fields and methods. There’s no need to have a separate lookup table or correlate with a new array of data.While traditional enums have a fixed set of values, ScriptableObject enums can be created and modified at runtime, allowing you to add or remove values as needed.If you have a long list of enum values without explicit numbering, inserting or removing an enum can change their order. This reordering can introduce subtle bugs or unintended behavior. ScriptableObject-based enums don’t have these issues. You can delete or add to your project without having to change the code every time.Suppose you want to make an item equippable in an RPG. You could append an extra boolean field to the ScriptableObject to do that. Are certain characters not allowed to hold certain items? Are some items magical or do they have special abilities? ScriptableObject-based enums can do that.Because you can create methods on a ScriptableObject, they are as useful for containing logic or actions as they are for holding data. Moving logic from your MonoBehaviour into a ScriptableObject enables you to use the latter as a delegate object, making the behavior more modular.If you need to perform specific tasks, you can encapsulate their algorithms into their own objects. The original Gang of Four refers to this general design as the strategy pattern. The example below shows how to make the strategy pattern more useful by using an abstract class to implement EnemyAI. The result is several derived ScriptableObjects with different behavior, which then becomes a pluggable behavior since each asset is interchangeable. You just drag and drop the ScriptableObject of choice into the MonoBehaviour.For a detailed example showing how to use ScriptableObjects to drive behavior, watch the video series Pluggable AI with ScriptableObjects. These sessions demonstrate a finite state machine-based AI system that can be configured using ScriptableObjects for states, actions, and transitions between those states.A common challenge in larger projects is when multiple GameObjects need to share data or states by avoiding direct references between these objects. Managing these dependencies at scale can require significant effort and is often a source of bugs. Many developers use singletons – one global instance of a class that survives scene loading. However, singletons introduce global states and make unit testing difficult. If you’re working with a Prefab that references a singleton, you’ll end up importing all of its dependencies just to test an isolated function. This makes your code less modular and efficient to debug.One solution is to use ScriptableObject-based events to help your GameObjects communicate. In this case, you are using ScriptableObjects to implement a form of the observer design pattern, where a subject broadcasts a message to one or more loosely decoupled observers. Each observing object can react independently from the subject but is unaware of the other observers. The subject can also be referred to as the “publisher” or “broadcaster” and the observers as “subscribers” or “listeners.”You can implement the observer pattern with MonoBehaviours or C# objects. While this is already common practice in Unity development, a script-only approach means your designers will rely on the programming team for every event needed during gameplay.At first glance, it appears that you’ve added a layer of overhead to the observer pattern, but this structure offers some advantages. Since ScriptableObjects are assets, they are accessible to all objects in your hierarchy and don’t disappear on scene loading.Easy, persistent access to certain resources is why many developers use singletons. ScriptableObjects can often provide the same benefits without introducing as many unnecessary dependencies.In ScriptableObject-based events, any object can serve as publisher (which broadcasts the event), and any object can serve as a subscriber (which listens for the event). The ScriptableObject sits in the middle and helps relay the signal, acting like a centralized intermediary between the two.One way to think about this is as an “event channel.” Imagine the ScriptableObject as a radio tower that has any number of objects listening for its signals. An interested MonoBehaviour can subscribe to the event channel and respond when something happens.The demo shows how the observer pattern helps you set up game events for UI, sounds, and scoring.At runtime, you’ll often need to track a list of GameObjects or components in your scene. For example, a list of enemies is something you’d need to frequently access, but it’s also a dynamic list that changes as more enemies are spawned or defeated. The singleton offers easy global access, but it has several drawbacks. Instead of using a singleton, consider storing data on a ScriptableObject as a “Runtime Set.” The ScriptableObject instance appears at the project level, which means it can store data that’s available to any object from any scene, offering similar global access. Since the data is located on an asset, its public list of items is accessible at any time.In this use case, you get a specialized data container that maintains a public collection of elements but also provides basic methods to add to and remove from the collection. This can reduce the need for singletons and improve testability and modularity.Reading data directly from a ScriptableObject is also more optimal than searching the Scene Hierarchy with a find operation like Object.FindObjectOfType or GameObject.FindWithTag. Depending on your use case and the size of your hierarchy, these are relatively expensive methods that can be inefficient for per-frame updates.There are several ScriptableObjects frameworks which offer more use cases than these six scenarios. Some teams decide to use ScriptableObjects extensively, while others limit their use to loading in static data and separating logic from data. Ultimately, the needs of your project will determine how you use them.Create modular game architecture in Unity with ScriptableObjects is the third guide in our series for intermediate to advanced Unity programmers. Each guide, authored by experienced programmers, provides best practices for topics that are important to development teams.Create a C# style guide: Write cleaner code that scales assists you with developing a style guide to help unify your approach to creating a more cohesive codebase.Level up your code with game programming patternshighlights best practices for using the SOLID principles and common programming patterns to create scalable game code architecture in your Unity project.We created this series to provide actionable tips and inspiration to our experienced creators, but they aren’t rule books. There are many ways to structure your Unity project and what might seem like a natural fit for one application may not be for another. Evaluate the advantages and disadvantages of each recommendation, tip, and pattern with your colleagues before deploying it.Find more advanced guides and articles on the Unity best practices hub.
    0 Comentários 0 Compartilhamentos