Skip navigation

Tag Archives: code

I’ve been working on automating the builds for our Unity project at work and been stymied the past couple of days with the project refusing to compile when I try to build from the command-line.

Here’s the situation, I just want to build a prototype build pipeline for a Unity project for our continuous integration efforts. In order to do that, I need to use Unity’s command line features so that a build server of some flavor can hook in to the Unity application and perform the build automatically.

In order to actually build something executable, in my case a Windows EXE file, the BuildPipeline object needs to be used. Specifically, the BuildPipeline.BuildPlayer function (see the sample code on that page).

Now comes the problem. The UnityEditor library is NOT allowed to be used in a built game! So every attempt at building my simple project resulted in compilation errors. Errors stating:

error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?

After two days of internet searching and following lots of blogs, forums, and youtube videos, I threw my hands up and posted on Stackoverflow. Within a few hours, I had the answer.

Create a folder with the name ‘Editor’, and place your scripts in there. According to the Unity’s Special Folders documentation, scripts place in this folder add “functionality to the Editor during development, and are not available in builds at runtime”.

I also confirmed that the pre-processor wrapping that was suggested worked as well.

So the answer was very easy to implement, but I am still frustrated that this critical piece of information is not made more apparent, especially by Unity’s own documentation.

Inside WordPress’s WYSIWYG editor, if you start a line of text, inside a code tag with a bad character, in my case, the ‘#’ character, the output gets screwed up. Here’s how to fix it.

If anyone looked at my previous post in the first week or two after I posted it, you may have noticed how ugly the post was when it came to the displaying my console’s output. This is because I put the console’s output inside a <code> tag in the WordPress WYSIWYG editor. My intent was to differentiate my blog post text from the output of the console I was using as an example. However, after wrapping the console output in the tag, this is what it looked like:

Code Tag with Incorrect Output

 

I have successfully used the <code> tag in WordPress before to stylize blocks of text, so that’s what I was using here to represent the console output. I didn’t have any trouble in any previous posts, so I wasn’t sure what was different this time. After experimenting a bit, I found that the “#” character that begins each line was the culprit.

code tag with a bad character at the start of each line

 

The fix was simple, I added a space before each line.

Code tag with a bad character, but prepended with spaces

 

This small change gave the output the desired effect.

Code output with corrrect formatting

 

%d bloggers like this: