SlideShare a Scribd company logo
1 of 48
The Hack Spectrum: 
Tips, Tricks, and Hacks for Unity 
Ryan Hipple 
Senior Engineer 
Schell Games 
@roboryantron
The World of Lexica 
● Transformational game 
● Tablets in the classroom 
● More than 50 people 
● 2 ½ years
The Hack Spectrum: 
Tips, Tricks, and Hacks for Unity 
Serialization 
Assets 
Runtime 
Reflection
The Hack Spectrum: 
Tips, Tricks, and Hacks for Unity 
Serialization 
Assets 
Runtime 
Reflection
Serialization 
Polymorphic Serialization 
● Polymorphism is awesome 
● Unity does not serialize it well (fields or arrays) 
Name 
Name Name Name 
Intelligence Ferocity Deliciousness
Serialization 
Polymorphic Serialization 
● ScriptableObject instead of [Serializable] 
● One problem : lots of files
Serialization 
Polymorphic Serialization 
● Want to make it one file... 
● AssetDatabase.AddObjectToAsset
Serialization 
Polymorphic Serialization 
● Want to make it seem like a normal file? 
● hideFlags = HideFlags.HideInHierarchy
Serialization 
Polymorphic Serialization 
● Streamline with custom inspectors 
● CreateInstance on Add 
● Destroy on Remove 
● Dropdown with available types
Serialization 
Polymorphic Serialization 
Demo
Serialization 
Serializable Long 
● 64 bit integer 
● Great for IDs 
● Used by other software 
● Unity does not serialize the type ‘long’
Serialization 
Serializable Long 
● Break into two ints for serialization 
● Custom Inspector 
● Implicit casting
The Hack Spectrum: 
Tips, Tricks, and Hacks for Unity 
Serialization 
Assets 
Runtime 
Reflection
Assets 
Auto Scriptable Objects 
● Not like assigning MonoBehaviours 
● Can only create ScriptableObjects from code
Assets 
Auto Scriptable Objects 
● Custom editor for MonoScript (inspector) 
● Check for ScriptableObject inheritance 
● Button to CreateInstance
Assets 
Auto Scriptable Objects 
Demo
Assets 
Default Object Inspector 
● No inspectors for directories 
● No inspectors for scenes 
● No inspectors for unknown extensions 
● No inspectors for asset roots
Assets 
Default Object Inspector 
● Create Custom Editor for “Object” 
● Draw differently for each type 
○ If statements? 
● Better Option - Copy Unity’s Inspector 
pattern
Assets 
Default Object Inspector 
● Custom Editor for Object 
● OnEnable, finds all “ObjectInspector” types 
○ Assembly.GetTypes 
● Any ObjectInspector where “IsValid” returns 
true is added to a list 
● Draw Valid Inspectors in OnInspectorGUI
Assets 
Default Object Inspector 
● Simple to Create 
● Extend ObjectInspector 
● Override IsValid 
○ example: return extension == (".unity"); 
● Override OnInspectorGUI
Assets 
Default Object Inspector 
Demo scene folder and file encoding
Assets 
Reusing Importer Settings 
● Often want same importer settings 
● Per project 
● Per directory 
● Should be automatic
Assets 
Reusing Importer Settings 
● Two-Part Solution 
○ AssetPostprocessor script 
○ Postprocessor settings scriptable objects 
● Each directory has a settings object 
● Override options for each importer option 
● Applies to new assets automatically
Assets 
Reusing Importer Settings 
Demo
Assets 
Custom Metadata 
● Data about a file - not in the file 
● Loading full file takes long 
● New objects can get deleted, renamed 
● Unity stores in meta file 
● You can too!
Assets 
Custom Metadata 
● AssetImporter.userData - string 
● Save key value pairs or json 
● Use AssetModificationProcessor to update 
● Display in inspector
Assets 
Custom Metadata 
Demo
The Hack Spectrum: 
Tips, Tricks, and Hacks for Unity 
Serialization 
Assets 
Runtime 
Reflection
Runtime 
References, Resources, and Memory 
● Useful to load a list of other assets 
● Object references in prefabs or SOs? 
○ Loads all assets at once 
● Paths for Resources.Load? 
○ Loads only when needed 
○ Typo prone
Runtime 
References, Resources, and Memory 
● Asset Path Attribute for string fields 
● Property Drawer for the attribute 
○ Draw as an object field 
○ Save path to string
Runtime 
Runtime Level Listing 
● At runtime, don’t know what scenes exist 
● EditorBuildSettings has a list 
● Lets steal it
Runtime 
Runtime Level Listing 
● AssetModificationProcessor for 
EditorBuildSettings.asset 
● Copy EditorBuildSettings.scenes to a 
ScriptableObject in Resources 
● Add any custom data in the list
Runtime 
Runtime Level Listing 
Demo
The Hack Spectrum: 
Tips, Tricks, and Hacks for Unity 
Serialization 
Assets 
Runtime 
Reflection
Reflection 
Reflection Primer 
● Information about all Assemblies and Types 
● Get a list of all types 
● List all functions in a type - Public or Private! 
● Call functions, set fields
Reflection 
Developer Debug Options 
● API Design - If it is public, they will call it 
● Attach to your API with reflection 
● Debugging 
● Testing
Reflection 
Call Editor Code from Game 
● If building DLLs, can’t use UnityEditor in 
game code 
● SelectGameObjectInHierarchy 
● Call your own editor code 
● EDITOR ONLY!
Reflection 
Call Editor Code from Game
Reflection 
Call Editor Code from Game 
Demo calling editor code from runtime
Reflection 
Use Private APIs 
● Unity exposes a lot out of the box 
● Much more to explore 
● Browse with ILSpy or Reflector
Reflection 
Use Private APIs 
● Open any editor window; issue commands 
● Take control of the window layout 
● “Borrow” editor assets 
● Tons of private calls waiting to be explored
Reflection 
Use Private APIs
Reflection 
Use Private APIs
Reflection 
Use Private APIs
Reflection 
Use Private APIs 
Demo window layout
The Hack Spectrum: 
Tips, Tricks, and Hacks for Unity 
Ryan Hipple 
Senior Engineer 
Schell Games 
@roboryantron

More Related Content

What's hot

Web PenTest Sample Report
Web PenTest Sample ReportWeb PenTest Sample Report
Web PenTest Sample Report
Octogence
 
Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5
AfiqEfendy Zaen
 

What's hot (20)

Computer System Security
Computer System SecurityComputer System Security
Computer System Security
 
Cyber-Security-.ppt
Cyber-Security-.pptCyber-Security-.ppt
Cyber-Security-.ppt
 
DoS or DDoS attack
DoS or DDoS attackDoS or DDoS attack
DoS or DDoS attack
 
Using Canary Honeypots for Network Security Monitoring
Using Canary Honeypots for Network Security MonitoringUsing Canary Honeypots for Network Security Monitoring
Using Canary Honeypots for Network Security Monitoring
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 
Trojan horse
Trojan horseTrojan horse
Trojan horse
 
API Security Fundamentals
API Security FundamentalsAPI Security Fundamentals
API Security Fundamentals
 
The Art of Human Hacking : Social Engineering
The Art of Human Hacking : Social Engineering The Art of Human Hacking : Social Engineering
The Art of Human Hacking : Social Engineering
 
Computer virus
Computer virusComputer virus
Computer virus
 
Cyber terrorism
Cyber terrorismCyber terrorism
Cyber terrorism
 
Web PenTest Sample Report
Web PenTest Sample ReportWeb PenTest Sample Report
Web PenTest Sample Report
 
DDoS - Distributed Denial of Service
DDoS - Distributed Denial of ServiceDDoS - Distributed Denial of Service
DDoS - Distributed Denial of Service
 
2018 - Using Honeypots for Network Security Monitoring
2018 - Using Honeypots for Network Security Monitoring2018 - Using Honeypots for Network Security Monitoring
2018 - Using Honeypots for Network Security Monitoring
 
Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
Agile Requirements Decomposition
Agile Requirements DecompositionAgile Requirements Decomposition
Agile Requirements Decomposition
 
Penetration Testing Guide
Penetration Testing GuidePenetration Testing Guide
Penetration Testing Guide
 
Botnets 101
Botnets 101Botnets 101
Botnets 101
 
Android Hacking
Android HackingAndroid Hacking
Android Hacking
 
DDoS Attacks
DDoS AttacksDDoS Attacks
DDoS Attacks
 

Similar to The Hack Spectrum: Tips, Tricks, and Hacks for Unity

Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
Marcos Quesada
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
Vasil Remeniuk
 

Similar to The Hack Spectrum: Tips, Tricks, and Hacks for Unity (20)

【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
FMX 2017: Extending Unreal Engine 4 with Plug-ins (Master Class)
FMX 2017: Extending Unreal Engine 4 with Plug-ins (Master Class)FMX 2017: Extending Unreal Engine 4 with Plug-ins (Master Class)
FMX 2017: Extending Unreal Engine 4 with Plug-ins (Master Class)
 
Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!
 
Android developer fundamentals training overview Part II
Android developer fundamentals training overview Part IIAndroid developer fundamentals training overview Part II
Android developer fundamentals training overview Part II
 
0507 057 01 98 * Adana Cukurova Klima Servisleri
0507 057 01 98 * Adana Cukurova Klima Servisleri0507 057 01 98 * Adana Cukurova Klima Servisleri
0507 057 01 98 * Adana Cukurova Klima Servisleri
 
Optimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark HarknessOptimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark Harkness
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
 
Flash develop presentation
Flash develop presentationFlash develop presentation
Flash develop presentation
 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game Framework
 
Python Spyder IDE | Edureka
Python Spyder IDE | EdurekaPython Spyder IDE | Edureka
Python Spyder IDE | Edureka
 
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay
GDC 2010 - A Dynamic Component Architecture for High Performance GameplayGDC 2010 - A Dynamic Component Architecture for High Performance Gameplay
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay
 
Pentester++
Pentester++Pentester++
Pentester++
 
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
 
Oren rubin statistical element locator
Oren rubin   statistical element locatorOren rubin   statistical element locator
Oren rubin statistical element locator
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
 
Ansiblefest 2018 Network automation journey at roblox
Ansiblefest 2018 Network automation journey at robloxAnsiblefest 2018 Network automation journey at roblox
Ansiblefest 2018 Network automation journey at roblox
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8
 
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
 
React native: building native iOS apps with javascript
React native: building native iOS apps with javascriptReact native: building native iOS apps with javascript
React native: building native iOS apps with javascript
 

Recently uploaded

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
 

Recently uploaded (20)

Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 

The Hack Spectrum: Tips, Tricks, and Hacks for Unity