- Home /
Why won't this (very simple) editor script compile? CS1041
Hi. My code is below. what i'm trying to do here is just completely disable all automatic-rotation behaviour by unity. I want all my objects to be imported as-is, with zero rotation on all axes. I figured the simplest way to do this would just be to overwrite the value in postprocessor after unity is done screwing up my models.
It fails to compile with the following error: Assets/Editor/CustomImportSettings.cs(13,38): error CS1041: Identifier expected
So basically this is a newbie question, what have i done wrong with the formattng ? I'm new to editor scripting and not entirely sure what's expected here, i just copied a function from this page: http://docs.unity3d.com/ScriptReference/AssetPostprocessor.OnPostprocessModel.html and modified it slightly
using UnityEngine;
using UnityEditor;
using System;
public class CustomImportSettings : AssetPostprocessor
{
public const float importScale= 1.0f;
void OnPreprocessModel()
{
ModelImporter importer = assetImporter as ModelImporter;
importer.globalScale = importScale;
}
function OnPostprocessModel (g : GameObject)
{
g.transform.rotation = new Vector3(0, 0, 0);
}
}
Answer by Habitablaba · Oct 24, 2014 at 09:55 PM
You're mixing C# and Java code. Change
function OnPostprocessModel (g : GameObject)
{
g.transform.rotation = new Vector3(0, 0, 0);
}
to
void OnPostprocessModel (GameObject g)
{
g.transform.rotation = new Vector3(0, 0, 0);
}
Alar$$anonymous$$gly, the example code doesn't change when you change the language you want, so selecting C# gives you JS code. This is most likely what went wrong for you.
ha, thank you. I actually just figured that out and was about to delete the thread, before you posted.
But you get a Green Tick anyway, thanks :P
I've submitted a documentation bug report and have cross-linked this question.
Your answer
![](https://koobas.hobune.stream/wayback/20220613165900im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I change the default max size of a texture from an editor script (in import settings)? 1 Answer
Material.mainTexture not working outside of runtime? 1 Answer
Is there a way to get a unique hash for an asset? 1 Answer
How should prefabs be changed automatically based on updating a text file? 1 Answer
Can I get a callback when scripts have finished compiling? 3 Answers