- Home /
pragma strict on a editor script.
I have these 2 errors when enabling pragma strict on a simple editor script:
Assets/StasisDevelopments/power set/files/scripts/editor/testeditor.js(8,24): BCE0019: 'value1' is not a member of 'UnityEngine.Object'.
Assets/StasisDevelopments/power set/files/scripts/editor/testeditor.js(8,73): BCE0019: 'value1' is not a member of 'UnityEngine.Object'.
I made this little test to easily duplicate the problem and I use javascript/uniscript
test.js :
#pragma strict
var value1 : boolean = false;
testeditor.js :
#pragma strict
@CustomEditor (test)
class testeditor extends Editor
{
function OnInspectorGUI()
{
target.value1 = EditorGUILayout.Toggle("Value1", target.value1);
}
}
Commenting out pragma strict makes it works fine.
Nobody? I guess pragma strict and a editor script don't go together?
What is target exactly? I don't see it declared anywhere in this code excerpt. Also, why use pragma strict when you don't have to? All it really does it disable dynamic typing, and you don't really need to disable it when you're not compiling for a platform that doesn't agree with it.
What errors are you getting exactly? What are you seeing, and what do you expect to happen? We need more information.
All pragma strict does is disable dynamic typing. It would help if you'd format code so it was more readable.
Edited the orriginal post for alot more clarity. copying code in unityawnsers is always a pain, got it into a decent format copying line per line...
Target is the target script, its never declared its just how the editorscript works using the example in the documentation.
Since unity started using monodevelop it automaticly adds pragma strict to new created scripts and since I am not that expirinced I asumed it was advised to use this.
Answer by tw1st3d · May 14, 2012 at 10:33 PM
#pragma strict causes the coding to force unity to show errors on anything that the editor will normally "let slide." This gives you an error-proof debugging system instead of having warnings when you compile.
Your answer

Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Pragma Strict Question/Problem 1 Answer
How do I apply Default-Diffuse material to a MeshRenderer in code? 6 Answers
How to import the object from server to unity 2 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers