Posted by: Morten Nobel-Jørgensen | October 23, 2010

Change the default language for the local Unity script reference in Chrome


Working with Unity also means working with the script reference a lot. I think the script reference is very good and has good code-snippets. One thing that has annoyed me is the default language is set to JavaScript and in this blog I’ll show how to change the default language.

After a bit of research I found out that the problem apparently only exist in the Chrome browser. Google Chrome does not allow cookies for local files to be read and saved for security reasons.

To change the default language into C# use the following hack:

Find the file jquery.cookie.js, it should be located in your Unity program folder under Documentation/Images. Open the file in a text editor (notepad or similar) and append the following code to the end of the file:


// simple fix to hardcode the default language
// (reason: cookies for local files does not work in Chrome)
$.cookie = function(cookieName){
	return "C#";
}

After saving the file you have now hardcoded the default language to C# – for all the content in the local Unity script reference. Note: you may need to force a reload in Chrome using ctrl+click reload for the changes to take effect.

Advertisements

Responses

  1. How does unity script relate to chrome? script referencing is calling objects from other parts of the game. i am a noob please explain.

    • I’m actually not talking about Unity at all. Only Unity documentation. If you use the offline documentation in Unity, the default language is UnityScript (aka. JavaScript) – and there is no way to change the default language permanent … unless you use the workaround I describe.

  2. Brilliant! I’ve been annoyed by the fact that JavaScript is set to default and I cannot change it to my beloved C#. Thanks a lot! 🙂

    By the way. Do you know how to set MonoDevelop (the default editor that comes with Unity3D) to open local scripting reference/manual when developer (means Me) hit F1 or something on selected class name?
    There is F12 which opens Assembly Browser but this is just a bunch of classes both from .net and Unity and there’s no examples also and I’d like to open reference for me automaticaly on correct topic instead of me opening it up by myself and the searching it for myself.

  3. It doesn’t work for me. I added in jquery.cookie.js it after the }; and before it. But nothing seems to change.

  4. Chrome doesn’t allow to save cookies for local files, here’s a solution I came up with:

    1. Open Documentation/StaticFiles/SelectCategory.js
    2. Append the following code:

    function getLanguage() {
    // C# is at index 1 in the dropdown
    return 1;
    }

  5. Chrome doesn’t store cookies on local files, here’s a solution I came up with:

    1. Open Documentation/StaticFiles/SelectCategory.js
    2. Append the following code:

    function getLanguage() {
    // C# is at index 1 in the combo
    return 1;
    }


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: