From the course: Unity 5: Build a Character Dialogue System
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Use interfaces - Unity Tutorial
From the course: Unity 5: Build a Character Dialogue System
Use interfaces
- [Instructor] If you've been around programming for a while, you'll be familiar with the idea of programming to an interface over an implementation. However, if this is a new concept to you, let's define what it actually means. In languages that support inheritance, like C Sharp, passing down functionality, usually leads to really complicated inheritance trees, where creating a new class may necessitate creating new sub classes just to make the inheritance structure work. Now this can get really messy. This is a visual representation of what a very simple inheritance tree might look like. With simple inheritance trees, this is perfectly fine, but this can get easily cluttered the bigger and more complex your program gets. Interfaces lend a more flexible solution to sharing functionality between classes that might not be alike at all, which makes using inheritance a hassle and often leads to cluttered class hierarchies. By extracting out those shared methods and or variables into an…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.