RenderToCubemap problem

Hi, I’m trying to get this script to work, but I have some problems.

Link to script

I have put it in the Assets/Editor folder And called it RenderToCubemap.cs, but I get an error in the editor:

Assets/Editor/RenderToCubemap.cs(5,27): error CS8025: Parsing error

I tried to add

using UnityEditor;

in the script, but that didn’t help.

Anyone who know what my problem is here? (Other than I’m not a programmer)

The script you linked to is written in Javascript, but you created a C# file. Try removing it and creating a .js file instead.

Hi, I tried that, but it gave me an even bigger error report:

NullReferenceException
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000]
System.Activator.CreateInstance (System.Type type, Boolean nonPublic) 
System.Activator.CreateInstance (System.Type type) 
UnityEditor.ScriptableWizard.DisplayWizard (System.String title, System.Type klass, System.String createButtonName, System.String otherButtonName)   (at C:\builds\unity-trunk\unity\Editor\Mono\Generated\ScriptableWizard.cs:91)
UnityEditor.ScriptableWizard.DisplayWizard (System.String title, System.Type klass, System.String createButtonName)   (at C:\builds\unity-trunk\unity\Editor\Mono\Generated\ScriptableWizard.cs:82)
UnityEditor.EditorWindow..ctor ()   (at C:\builds\unity-trunk\unity\Editor\Mono\Generated\EditorWindow.cs:266)
UnityEditor.ScriptableWizard..ctor () 
RenderCubemapWizard..ctor ()   (at Assets\Editor\RenderToCubemap.js:1)
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]

Hi, look at this page :

http://unity3d.com/support/resources/unite-presentations/using-the-unity-editor-apis

Jon Czeck will save you with his bundle of scripts :smile:

They work perfectly in Unity 2.5, and he included RenderToCubeMap.

Be aware that this version will now be accessible from the “Custom” menu, together with a bunch of great other scripts (just love that “deselect” shortcut with the “A” key, thanks so much Jon !)

You got my hopes up there. But when I installed the bundle and tried to use the cubemapwizard I got this below.

I have no clue where to start fixing that!

169650--6111--$graveck_109.jpg

This is what I’m getting with the Graveck editor package.

I imported the assets in the usual way. What is going on?

The errors are self explaining
The class in the C# file needs to have the same name as the file (and you shouldn’t have a . in)

I’m sorry Dremora, I don’t understand. I just downloaded this package. I don’t script at all and I don’t know which bit is the class or which . you mean.

Weird. I just checked again : create a new project in Unity 2.5 for Mac, double-click on “Graveck Editor Package.unityPackage”, everything imports smoothly.

Then I would recommend to learn the basics about scripting first before you start throwing in 3rd party stuff

Dremora, I’m trying. It helps enormously when the manual explains things. It is the Unity script, which is not third party, that I was trying to get working in the first place and I tried Yann’s suggestion because I couldn’t figure out why it wasn’t working. Also the Graveck stuff is a download from the Unity website and it looks very good. If I can get it to work.

Yann.

OK, I did as you suggested and imported the assets into a new project. It worked OK i just got a few different errors. They only apply to one script though so I’ll probably ditch it for now. I don’t know why I can’t import it into the project I’m working on but weirdness abounds with this project at the moment and I’m having all sorts of trouble.

I’ll try and import them into the other project one by one.

RHD, your editor scripts should remain in a folder named “Editor”. Your screen capture shows that you put them in a a “Script” folder. Your first screen capture, that is.

Have you tried to move the Editor and Plugins folders to the Assets folder’s first level ?

Yann, thanks!

OK, I restarted, and reimported the Graveck Editor Package. This time it’s come in fine, not so much as a wimper from the console.

The reason the script is not in the Editor folder is that when I try and drop it on the camera, which I guess is what you do with it, I get an error message saying it can’t be used because it’s in the Editor folder. If I put it outside the Editor folder I get a different error message.

If you don’t add it to the camera you are trying to make the cubemap with, what do you do with it?

Thanks a million!

Editor scripts don’t have to be assigned to an object : their function is to extend Unity’s editor. You just use them, as you would use any other Unity editor function. In this case, go to the new “Custom” menu, choose “Render Into Cubemap” and follow the instructions. The new cubemap will have to be assigned to an already existing cubemap asset, so you will have to create it from the “Assets/Create” general menu, or from the “Create” menu of your Assets folder if you don’t want to erase the existing ones.

Ha! You mean that huge honking new menu I hadn’t noticed!

It works!!! FANTASTIC!

Thank you so much Yann! If you ever come to London I owe you a drink!

I haven’t figured out how you save the render texture with a particular name or where it’s putting them but I expect I will eventually.

169677--6115--$birdy_724.jpg

Right! I’ve obviously erased an existing one. It must have been a standard asset somewhere.

I’ve just started getting to grips with attaching scripts to objects. Making things happen the old fashioned way, through the Edit menu threw me into a confusion!

Great bundle of assets. Thank you for drawing attention to them and for your patience helping me sort it out.

The cubemap looks fantastic. It’s wonderful when it works!