SlideShare a Scribd company logo
Rapid prototyping
in Unity using
ScriptableObjects
What I’ll talk about today
• What ScriptableObjects are

• How to create and use them

• Why they will make your life easier

• How they will make your designers happy

• Pros and cons

• Bonus: example project
Who I am
• Hi, my name is Giorgio Pomettini

• I teach programming and history of videogames at AIV

• I worked on several mobile projects in Unity

• Today it’s my birthday 🎂
Let’s start with a story
Rapid prototyping with ScriptableObjects
Player Enemy
GameObject.Find("Enemy").GetComponent<Enemy>().Damage();
Player Enemy
Enemy 2
Enemy 3
Enemy 4UI
Menu
Boss
Sword
Player Enemy
Enemy 2
Enemy 3
Enemy 4UI
Menu
Boss
Sword
Game
Manager
Player Enemy
Enemy 2
Enemy 3
Enemy 4UI
Menu
Boss
Sword
Game
Manager
Rapid prototyping with ScriptableObjects
What is a Singleton?
public class GameManager : MonoBehaviour
{
// Static instance of GameManager
// Which allows to be accessed from other scripts
public static GameManager Instance = null;
void OnAwake()
{
Instance = this;
}
}
What is a Singleton?
public class GameManager : MonoBehaviour
{
public static GameManager Instance = null;
public int Score;
void OnAwake()
{
Instance = this;
}
}
public class SampleUI : MonoBehaviour
{
public Text ScoreLabel;
void Update()
{
ScoreLabel.text = GameManager.Instance.Score.ToString();
}
}
Singleton Pros
• They are globally accessible

• They hold persistent data*

• They are easy to implement
Singleton Cons
• Rigid connection

• No polymorphism

• Hard to test

• There can be only one instance
Introducing
ScriptableObjects
What are ScriptableObjects
• It’s like a MonoBehaviour, but it’s not a Component

• Can not be attached to GameObjects

• Can be serialized (can be transformed into a format that
Unity can store and reconstruct later)
• Saved as .asset file
public class SampleScriptableObject : ScriptableObject
{
}
What are ScriptableObjects
public class PokemonEntry : ScriptableObject
{
public string Name;
public int BaseHP;
public int BaseAttack;
public int BaseDefense;
public int BaseSpeed;
}
Example
[CreateAssetMenu]
Example
Example
public class Pokedex : MonoBehaviour
{
public PokemonEntry Entry;
void Start()
{
Debug.LogFormat("{0} has {1} Base HP", Entry.Name, Entry.BaseHP);
}
}
Output: Pikachu has 35 Base HP
Common use cases
• Game config files

• Cards

• Inventory

• Pokemon Enemy stats

• Any type of shared data that needs tweaking
C# Script C# Script
Serialized by Unity Serialized by Unity
Can use custom Editors Can use custom Editors
OnEnable/OnDisable callbacks OnEnable/OnDisable callbacks
Update and other callbacks No Update callbacks
Lives in scenes or prefabs Lives on disk or in memory
Data is reset when exiting Play Mode Stores data when exiting Play Mode
MonoBehaviour vs ScriptableObject
ScriptableObjects callbacks
• OnEnable()
• Called when instanced or loaded

• Also called after a script recompilation

• OnDestroy()
• Called after Object.Destroy()

• OnDisable()
• Called right before OnDestroy() when object is about to be destroyed

• Also called before script recompilation
// Create an instance
var pokemon = ScriptableObject.CreateInstance<PokemonEntry>();
// Save to disk
AssetDatabase.CreateAsset(pokemon, "Assets/MyPokemon.asset");
// Or keep it in memory
pokemon.hideFlags = HideFlags.HideAndDontSave;
How to create them
// Make .asset from project view
[CreateAssetMenu]
Benefits
• Clean separation between data and code

• Can be created and used easily by designers

• Keeps data while editing in play mode

• They work well with version control systems such as Git

• Your scenes and prefabs will load faster (why?)
Examples
Enums
• Must change in code

• Difficult to remove or reorder

• Solution: Pluggable Enums

• Empty ScriptableObjects that can be created and
assigned by designers

• Can hold additional data

• Supports null
Enums
[CreateAssetMenu]
public class PokemonStatus : ScriptableObject
{
}
Better Enums
[CreateAssetMenu]
public class PokemonType : ScriptableObject
{
public List<PokemonType> NoEffect;
public List<PokemonType> NotEffective;
public List<PokemonType> SuperEffective;
}
Better Enums
Normal attacks Ghost
Does the Ghost’s list of no effects types contains Normal?
If so, the attack does no effect
[Check other conditions]
Better Enums
public class PokemonTypesTester : MonoBehaviour
{
public PokemonType AttackingType;
public PokemonType DefendingType;
void Start()
{
string message = AttackingType.name;
if (DefendingType.NoEffect.Contains(AttackingType))
message += " has no effect on ";
else if (DefendingType.NotEffective.Contains(AttackingType))
message += " is not effective on ";
else if (DefendingType.SuperEffective.Contains(AttackingType))
message += " is super effective on ";
else
message += " has normal effect on ";
message += DefendingType.name;
Debug.Log(message);
}
} Output: Normal has no effect on Ghost
ScriptableObjects
Architecture
• Designers can create and assign those variables

• They can plug them whenever they need it

• The value can change when the game is running

• Anything that references that value will get an update
Pluggable Variables
[CreateAssetMenu]
public class IntVariable : ScriptableObject
{
public int Value;
}
Pluggable Variables
public class Player : MonoBehaviour
{
public IntVariable Money;
public IntVariable Badges;
}
Use for values that needs to be shared, for instance:

• Score

• Player HP

• Timing data
Pluggable Variables
PlayerMoney
Player ItemShop
PlayerScreenUI
SafariZone
Pluggable Variables
[CreateAssetMenu]
public class FloatVariable : ScriptableObject
{
public float Value;
}
[CreateAssetMenu]
public class GameObjectList : ScriptableObject
{
List<GameObject> List;
}
Pluggable Events
UnityEvents
???
UnityEvents
UnityEvents
• Rigid connections (again)

• A button is referencing the object that responds to it

• Solution: Pluggable Events
• ScriptableObjects that sends messages to listeners
that can be created and assigned by designers

• Warning: They allocate (don’t invoke them in Update)
• They also can be a bit tricky to debug
Pluggable Events
OnPlayerDefeated
public class Player : MonoBehaviour
{
// Variables
public IntVariable Money;
public IntVariable Badges;
// Events
public GameEvent OnPlayerDefeated;
void Start()
{
OnPlayerDefeated.Raise();
}
}
Pluggable Events
OnPlayerDefeated
Player GameEventListener
OnPlayerDefeated.Raise();
[CreateAssetMenu]
public class GameEvent : ScriptableObject
{
private List<GameEventListener> eventListeners = new List<GameEventListener>();
public void Raise()
{
for (int i = eventListeners.Count - 1; i >= 0; i--)
eventListeners[i].OnEventRaised();
}
public void RegisterListener(GameEventListener listener)
{
if (!eventListeners.Contains(listener))
eventListeners.Add(listener);
}
public void UnregisterListener(GameEventListener listener)
{
if (eventListeners.Contains(listener))
eventListeners.Remove(listener);
}
}
Pluggable Events
Pluggable Events
public class GameEventListener : MonoBehaviour
{
public GameEvent Event;
public UnityEvent Response;
private void OnEnable()
{
Event.RegisterListener(this);
}
private void OnDisable()
{
Event.UnregisterListener(this);
}
public void OnEventRaised()
{
Response.Invoke();
}
}
OnPlayerDefeated
Player DecreaseMoney
GameOverScreen
TeleportPlayer
Pluggable Events
Designer-friendly FSMs
Patrol
ChaseAttack
Yes, ScriptableObjects can also have functions and not only data!
Designer-friendly FSMs
• Works like the State/Strategy Pattern

• You have different behaviors in different ScriptableObjects
and you swap them based on your needs
Designer-friendly FSMs
Unit Testing
• Have you tried testing a MonoBehaviour class?

• Yup, it’s almost impossible

• You often have tight dependencies

• You cannot instantiate them directly

• But you can do them with ScriptableObjects!

• You can make scripts to test them in isolation

• You can also easily create mock objects if needed
Wait, but was that a talk
about rapid prototyping?
Rapid prototyping
• Since ScriptableObjects are saved as .asset files, they’re
highly reusable between projects

• You can write scripts that accepts Pluggable Variables and
Pluggable Events so designers can “compose” behaviours
public class ImageFillSetter : MonoBehaviour
{
public FloatVariable Variable;
public float Min;
public float Max;
public Image Image;
private void Update()
{
// Sets image fill amount based on clamped value of FloatVariable
Image.fillAmount = Mathf.Clamp01(Mathf.InverseLerp(Min, Max, Variable.Value));
}
}
Rapid prototyping
Designer
Frameworks
https://github.com/AdamRamberg/unity-atoms
Frameworks
https://github.com/DanielEverland/ScriptableObject-Architecture
References used
• Unite 2016 - Overthrowing the MonoBehaviour Tyranny in
a Glorious Scriptable Object Revolution (Richard Fine)
• Unite Austin 2017 - Game Architecture with Scriptable
Objects (Ryan Hipple)
• Unite '17 Seoul - ScriptableObjects What they are and
why to use them (Ian Dundore)
• Unity Blog - Making cool stuff with ScriptableObjects
(Matt Shell)
Demo time!
Thank you!
Questions?
• Mail: giorgio.pomettini@gmail.com

• Website: www.videogio.co

• Company: Accademia Italiana Videogiochi

• Twitter: @dreamquest

• Github: @pomettini

More Related Content

PPTX
Unreal Engine (For Creating Games) Presentation
PPTX
Game Architecture with Scriptable Objects
PPTX
Game Project / Working with Unity
PPTX
Android mp3 player
PPTX
Deep dive into Java security architecture
PDF
Declarative UIs with Jetpack Compose
PDF
Unreal Engine Basics 02 - Unreal Editor
PDF
AI and ML Skills for the Testing World Tutorial
Unreal Engine (For Creating Games) Presentation
Game Architecture with Scriptable Objects
Game Project / Working with Unity
Android mp3 player
Deep dive into Java security architecture
Declarative UIs with Jetpack Compose
Unreal Engine Basics 02 - Unreal Editor
AI and ML Skills for the Testing World Tutorial

What's hot (20)

PDF
Understanding the Android System Server
PPTX
UNITY 3D.pptx
PDF
Gamifying Education: The Octalysis Framework
PPTX
Flutter
PDF
Building beautiful apps with Google flutter
DOC
Nitin resume dev_ops
PDF
Authorization and Authentication in Microservice Environments
PPTX
Functional Patterns with Java8 @Bucharest Java User Group
PPT
Android ppt
PPT
Introduction to Unity3D Game Engine
PDF
idsecconf2023 - Rama Tri Nanda - Hacking Smart Doorbell.pdf
PDF
Android life cycle
PPTX
Unity - Game Engine
PDF
Three.js basics
PDF
Mobile Game Development in Unity
PPT
Spring Core
PDF
MMO Design Architecture by Andrew
PDF
Unity Introduction
PDF
Unreal Engine Basics 03 - Gameplay
PPS
Cerny method
Understanding the Android System Server
UNITY 3D.pptx
Gamifying Education: The Octalysis Framework
Flutter
Building beautiful apps with Google flutter
Nitin resume dev_ops
Authorization and Authentication in Microservice Environments
Functional Patterns with Java8 @Bucharest Java User Group
Android ppt
Introduction to Unity3D Game Engine
idsecconf2023 - Rama Tri Nanda - Hacking Smart Doorbell.pdf
Android life cycle
Unity - Game Engine
Three.js basics
Mobile Game Development in Unity
Spring Core
MMO Design Architecture by Andrew
Unity Introduction
Unreal Engine Basics 03 - Gameplay
Cerny method
Ad

Similar to Rapid prototyping with ScriptableObjects (20)

PDF
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
PDF
Scriptable Objects in Unity Game Engine (C#)
PPTX
Unity3D Programming
PDF
unity-clinic2-unityscript-basics
PDF
School For Games 2015 - Unity Engine Basics
PDF
How tomakea gameinunity3d
PPTX
Extending unity3D Editor
PPTX
Overview of C# Script for Unity Game Development
PDF
Анатолій Ландишев - “Незв’язний код у Unity” GameCC 2017
PPTX
Unity workshop
PDF
Unit testing in Unity
PDF
Introduction to Unity by Purdue university
PPTX
Academy PRO: Unity 3D. Scripting
PPTX
Optimizing mobile applications - Ian Dundore, Mark Harkness
PDF
Start Building a Game and Get the Basic Structure Running
PDF
Unity 3d scripting tutorial
PDF
2%20-%20Scripting%20Tutorial
PDF
2%20-%20Scripting%20Tutorial
PPTX
Adding Love to an API (or How to Expose C++ in Unity)
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
Scriptable Objects in Unity Game Engine (C#)
Unity3D Programming
unity-clinic2-unityscript-basics
School For Games 2015 - Unity Engine Basics
How tomakea gameinunity3d
Extending unity3D Editor
Overview of C# Script for Unity Game Development
Анатолій Ландишев - “Незв’язний код у Unity” GameCC 2017
Unity workshop
Unit testing in Unity
Introduction to Unity by Purdue university
Academy PRO: Unity 3D. Scripting
Optimizing mobile applications - Ian Dundore, Mark Harkness
Start Building a Game and Get the Basic Structure Running
Unity 3d scripting tutorial
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial
Adding Love to an API (or How to Expose C++ in Unity)
Ad

More from Giorgio Pomettini (6)

PDF
Let's make a game for the Playdate
PDF
Fate spazio al mio nuovo sito web: VR room scale su browser con A-Frame e HTC...
PDF
Primi passi con ARKit & Unity
PDF
Fist Of Fury (Roads): Come ho tradotto un gioco in Cinese in 48 ore
PDF
Rust & Gamedev
PDF
Facciamo un gioco retrò in HTML5 con PICO-8
Let's make a game for the Playdate
Fate spazio al mio nuovo sito web: VR room scale su browser con A-Frame e HTC...
Primi passi con ARKit & Unity
Fist Of Fury (Roads): Come ho tradotto un gioco in Cinese in 48 ore
Rust & Gamedev
Facciamo un gioco retrò in HTML5 con PICO-8

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
web development for engineering and engineering
DOCX
573137875-Attendance-Management-System-original
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
additive manufacturing of ss316l using mig welding
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Geodesy 1.pptx...............................................
PDF
composite construction of structures.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
CH1 Production IntroductoryConcepts.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Internet of Things (IOT) - A guide to understanding
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
web development for engineering and engineering
573137875-Attendance-Management-System-original
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Mechanical Engineering MATERIALS Selection
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
additive manufacturing of ss316l using mig welding
OOP with Java - Java Introduction (Basics)
Geodesy 1.pptx...............................................
composite construction of structures.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...

Rapid prototyping with ScriptableObjects

  • 1. Rapid prototyping in Unity using ScriptableObjects
  • 2. What I’ll talk about today • What ScriptableObjects are • How to create and use them • Why they will make your life easier • How they will make your designers happy • Pros and cons • Bonus: example project
  • 3. Who I am • Hi, my name is Giorgio Pomettini • I teach programming and history of videogames at AIV • I worked on several mobile projects in Unity • Today it’s my birthday 🎂
  • 7. Player Enemy Enemy 2 Enemy 3 Enemy 4UI Menu Boss Sword
  • 8. Player Enemy Enemy 2 Enemy 3 Enemy 4UI Menu Boss Sword Game Manager
  • 9. Player Enemy Enemy 2 Enemy 3 Enemy 4UI Menu Boss Sword Game Manager
  • 11. What is a Singleton? public class GameManager : MonoBehaviour { // Static instance of GameManager // Which allows to be accessed from other scripts public static GameManager Instance = null; void OnAwake() { Instance = this; } }
  • 12. What is a Singleton? public class GameManager : MonoBehaviour { public static GameManager Instance = null; public int Score; void OnAwake() { Instance = this; } } public class SampleUI : MonoBehaviour { public Text ScoreLabel; void Update() { ScoreLabel.text = GameManager.Instance.Score.ToString(); } }
  • 13. Singleton Pros • They are globally accessible • They hold persistent data* • They are easy to implement
  • 14. Singleton Cons • Rigid connection • No polymorphism • Hard to test • There can be only one instance
  • 16. What are ScriptableObjects • It’s like a MonoBehaviour, but it’s not a Component • Can not be attached to GameObjects • Can be serialized (can be transformed into a format that Unity can store and reconstruct later) • Saved as .asset file
  • 17. public class SampleScriptableObject : ScriptableObject { } What are ScriptableObjects
  • 18. public class PokemonEntry : ScriptableObject { public string Name; public int BaseHP; public int BaseAttack; public int BaseDefense; public int BaseSpeed; } Example [CreateAssetMenu]
  • 20. Example public class Pokedex : MonoBehaviour { public PokemonEntry Entry; void Start() { Debug.LogFormat("{0} has {1} Base HP", Entry.Name, Entry.BaseHP); } } Output: Pikachu has 35 Base HP
  • 21. Common use cases • Game config files • Cards • Inventory • Pokemon Enemy stats • Any type of shared data that needs tweaking
  • 22. C# Script C# Script Serialized by Unity Serialized by Unity Can use custom Editors Can use custom Editors OnEnable/OnDisable callbacks OnEnable/OnDisable callbacks Update and other callbacks No Update callbacks Lives in scenes or prefabs Lives on disk or in memory Data is reset when exiting Play Mode Stores data when exiting Play Mode MonoBehaviour vs ScriptableObject
  • 23. ScriptableObjects callbacks • OnEnable() • Called when instanced or loaded • Also called after a script recompilation • OnDestroy() • Called after Object.Destroy() • OnDisable() • Called right before OnDestroy() when object is about to be destroyed • Also called before script recompilation
  • 24. // Create an instance var pokemon = ScriptableObject.CreateInstance<PokemonEntry>(); // Save to disk AssetDatabase.CreateAsset(pokemon, "Assets/MyPokemon.asset"); // Or keep it in memory pokemon.hideFlags = HideFlags.HideAndDontSave; How to create them // Make .asset from project view [CreateAssetMenu]
  • 25. Benefits • Clean separation between data and code • Can be created and used easily by designers • Keeps data while editing in play mode • They work well with version control systems such as Git • Your scenes and prefabs will load faster (why?)
  • 27. Enums • Must change in code • Difficult to remove or reorder • Solution: Pluggable Enums • Empty ScriptableObjects that can be created and assigned by designers • Can hold additional data • Supports null
  • 29. Better Enums [CreateAssetMenu] public class PokemonType : ScriptableObject { public List<PokemonType> NoEffect; public List<PokemonType> NotEffective; public List<PokemonType> SuperEffective; }
  • 30. Better Enums Normal attacks Ghost Does the Ghost’s list of no effects types contains Normal? If so, the attack does no effect [Check other conditions]
  • 31. Better Enums public class PokemonTypesTester : MonoBehaviour { public PokemonType AttackingType; public PokemonType DefendingType; void Start() { string message = AttackingType.name; if (DefendingType.NoEffect.Contains(AttackingType)) message += " has no effect on "; else if (DefendingType.NotEffective.Contains(AttackingType)) message += " is not effective on "; else if (DefendingType.SuperEffective.Contains(AttackingType)) message += " is super effective on "; else message += " has normal effect on "; message += DefendingType.name; Debug.Log(message); } } Output: Normal has no effect on Ghost
  • 33. • Designers can create and assign those variables • They can plug them whenever they need it • The value can change when the game is running • Anything that references that value will get an update Pluggable Variables [CreateAssetMenu] public class IntVariable : ScriptableObject { public int Value; }
  • 34. Pluggable Variables public class Player : MonoBehaviour { public IntVariable Money; public IntVariable Badges; } Use for values that needs to be shared, for instance: • Score • Player HP • Timing data
  • 36. Pluggable Variables [CreateAssetMenu] public class FloatVariable : ScriptableObject { public float Value; } [CreateAssetMenu] public class GameObjectList : ScriptableObject { List<GameObject> List; }
  • 40. UnityEvents • Rigid connections (again) • A button is referencing the object that responds to it • Solution: Pluggable Events • ScriptableObjects that sends messages to listeners that can be created and assigned by designers • Warning: They allocate (don’t invoke them in Update) • They also can be a bit tricky to debug
  • 41. Pluggable Events OnPlayerDefeated public class Player : MonoBehaviour { // Variables public IntVariable Money; public IntVariable Badges; // Events public GameEvent OnPlayerDefeated; void Start() { OnPlayerDefeated.Raise(); } }
  • 43. [CreateAssetMenu] public class GameEvent : ScriptableObject { private List<GameEventListener> eventListeners = new List<GameEventListener>(); public void Raise() { for (int i = eventListeners.Count - 1; i >= 0; i--) eventListeners[i].OnEventRaised(); } public void RegisterListener(GameEventListener listener) { if (!eventListeners.Contains(listener)) eventListeners.Add(listener); } public void UnregisterListener(GameEventListener listener) { if (eventListeners.Contains(listener)) eventListeners.Remove(listener); } } Pluggable Events
  • 44. Pluggable Events public class GameEventListener : MonoBehaviour { public GameEvent Event; public UnityEvent Response; private void OnEnable() { Event.RegisterListener(this); } private void OnDisable() { Event.UnregisterListener(this); } public void OnEventRaised() { Response.Invoke(); } }
  • 46. Designer-friendly FSMs Patrol ChaseAttack Yes, ScriptableObjects can also have functions and not only data!
  • 47. Designer-friendly FSMs • Works like the State/Strategy Pattern • You have different behaviors in different ScriptableObjects and you swap them based on your needs
  • 49. Unit Testing • Have you tried testing a MonoBehaviour class? • Yup, it’s almost impossible • You often have tight dependencies • You cannot instantiate them directly • But you can do them with ScriptableObjects! • You can make scripts to test them in isolation • You can also easily create mock objects if needed
  • 50. Wait, but was that a talk about rapid prototyping?
  • 51. Rapid prototyping • Since ScriptableObjects are saved as .asset files, they’re highly reusable between projects • You can write scripts that accepts Pluggable Variables and Pluggable Events so designers can “compose” behaviours public class ImageFillSetter : MonoBehaviour { public FloatVariable Variable; public float Min; public float Max; public Image Image; private void Update() { // Sets image fill amount based on clamped value of FloatVariable Image.fillAmount = Mathf.Clamp01(Mathf.InverseLerp(Min, Max, Variable.Value)); } }
  • 55. References used • Unite 2016 - Overthrowing the MonoBehaviour Tyranny in a Glorious Scriptable Object Revolution (Richard Fine) • Unite Austin 2017 - Game Architecture with Scriptable Objects (Ryan Hipple) • Unite '17 Seoul - ScriptableObjects What they are and why to use them (Ian Dundore) • Unity Blog - Making cool stuff with ScriptableObjects (Matt Shell)
  • 59. • Mail: giorgio.pomettini@gmail.com • Website: www.videogio.co • Company: Accademia Italiana Videogiochi • Twitter: @dreamquest • Github: @pomettini