- Home /
I can't get any editor scripts working at all
Hi everyone. I'm trying to use any of several editor scripts i've found on the web, to fix the default import scale of fbx files.
The instructions i've found repeatedly, everywhere, are to put the script into my project folder, under Assets/Editor. So that's what i'm doing, although i had to manually create the editor folder as it wasn't there by default. Just to confirm, it's named "Editor" The full path looks like this:
I created a file in there called FBXScaleFix (Is the filename important?)with no filetype (ie, "all files") and pasted my code in. If unity is open it immediately generates a file called FBXScaleFix.txt.meta or does so on next run
Despite this, literally nothing happens. When i import fbx files they still come in with 0.01 scale.
As mentioned i've tried several scripts to do the same thing. And with each one, i replaced the text in the file, deleted the FBXScaleFix.txt.meta, then closed and reopened unity, then imported a brand new object None of them have any effect at all.
I get NO error messages of any sort, no feedback, nothing. I've made a good faith effort to diagnose this problem, something seems very wrong here
Anyways, code is below. Several different scripts i've tried and failed:
using UnityEngine;
using UnityEditor;
using System;
//Sets our settings for all new Models and Textures upon first import
public class CustomImportSettings : AssetPostprocessor
{
public const float importScale= 1.0f;
void OnPreprocessModel()
{
ModelImporter importer = assetImporter as ModelImporter;
importer.globalScale = importScale;
importer.generateMaterials = ModelImporterGenerateMaterials.None;
}
}
using UnityEngine; using UnityEditor;
class MeshPostprocessor : AssetPostprocessor {
void OnPreprocessModel () { (assetImporter as ModelImporter).globalScale = 1.0f; }
}
using UnityEditor;
public class FBXScaleFix : AssetPostprocessor { public void OnPreprocessModel() { ModelImporter modelImporter = (ModelImporter) assetImporter;
modelImporter.globalScale = 1;
}
}
Answer by Baste · Oct 23, 2014 at 11:45 AM
The script has to be a source code file - ie. a .cs file for C# code. To make the file work, simply ensure that it is a .cs file instead of a .txt file.
To be clear, you've saved the file as a .txt file, not as "no filetype". It shows up in explorer as "Text Document", and the .meta file is for FBXScaleFix.txt. If you just save a file from notepad, windows really wants it to have the (completely useless) .txt file extension.
I'd strongly recommend turning on file endings for known file types. Find the folder options (click the windows key, type in "folder option", select the view menu), and uncheck "Hide extensions for known file types".
Answer by Unitraxx · Oct 23, 2014 at 11:43 AM
When you create the FBXScaleFix file, you actually create a FBXScaleFix.txt file. What you want is a FBXScaleFix.cs file. You can either get this by manually changing the extension, or simply adding a C# script with the unity editor.
Answer by GameVortex · Oct 23, 2014 at 11:47 AM
A .txt file is just a plain text file and unity will import it as that. A plain text file does absolutely nothing else than contain text. To have your script work as a script in Unity it needs to have the correct script file extension. For Unityscript that is .js and for C# script that is .cs.
The script you have found is a C# script which means the file you create should be a .cs file.
Instead of creating the files directly in the folder you can more easily create it correctly by going into Unity and the Project view and select Create - C# Script. Then open that and paste your code in. As soon as you save it and go back to Unity you will see a small circle in the bottom right to show that it is compiling (might be over very quickly if you only have one script).
Your answer
Follow this Question
Related Questions
share or reassign materials 0 Answers
3DS Max Import Problem 2 Answers
Scene animation 0 Answers
problems importing animations 0 Answers