Skip navigation

Extension methods

Extension methods: Advanced Unity: 3D Game Programming
Extension methods: Advanced Unity: 3D Game Programming

Join for an in-depth discussion in this video Extension methods, part of Advanced Unity: 3D Game Programming.

Resume Transcript Auto-Scroll
Skill Level Advanced
3h 45m
Duration
201,086
Views
Show More Show Less

Q: In the Chapter 3 file EntityLoader.cs, I get an error: DirectoryNotFoundException: Directory 'Assets\' not found. Removing the backslash after 'Assets' fixes it, but then I run into a different error. How do I fix this?
 

A: Some operating systems (like Mac OS X) use different directory separator characters. To make the code more compatible with different OSs, use ` Path.DirectorySeparatorChar` instead of `\` in all instances in this code. The replacements result in the following code:
 
string dataFolder = @"Assets" + Path.DirectorySeparatorChar;
Dictionary<string, CustomPrefab> prefabs = new Dictionary<string,
CustomPrefab>();
// Use this for initializationvoid Start () {
foreach(string dataFile in Directory.GetFiles(dataFolder, "*.data",
SearchOption.AllDirectories)) {
string[] lines = File.ReadAllLines(dataFile);
string name =
dataFile.Substring(dataFile.LastIndexOf(Path.DirectorySeparatorChar)+1,
dataFile.LastIndexOf(".") -
(dataFile.LastIndexOf(Path.DirectorySeparatorChar)+1));
prefabs.Add(name, new CustomPrefab(name, lines));
}}

Q: What version of Unity does this course cover?

A:  This course requires Unity 4.5.5. The newer versions of Unity have done away with the GUI system used in this course, so the interfaces included for many of the scenes will not work with 4.6 and higher. You can download Unity 4.5.5 at http://unity3d.com/get-unity/download/archive.

Q: The game object in the first chapter's Mouse Input Raycasting sample doesn't appear to follow the mouse. What's wrong?

A: Please enable the Box Collider component (by activating the checkbox next to the component name) on the game object. This is not explicitly mentioned in the video, but it will ensure the raycasts collide with the game object.

Skills covered in this course
3D + Animation Developer Games Game Development Unity

Continue Assessment

You started this assessment previously and didn't complete it. You can pick up where you left off, or start over.

Start My Free Month

Start your free month on LinkedIn Learning, which now features 100% of Lynda.com courses. Develop in-demand skills with access to thousands of expert-led courses on business, tech and creative topics.

Start My Free Month

You are now leaving Lynda.com and will be automatically redirected to LinkedIn Learning to start your free trial.