Beruflich Dokumente
Kultur Dokumente
x
Language: English
Log in
Home
Unity
Industries
Showcase
Asset Store
Learn
Community
Download
Buy
Forums
Answers
Feedback
Issue Tracker
Evangelists
User Groups
Answers
Before updating to Windows 10 you may need to return your Pro license. More
information here
I'm making my game using C# scripts, and the variables aren't appearing in the
inspector, I could just go into the code to edit variables, but having them in the
inspector would be far more convenient.
I've tried every solution I found online, I've tried making the variables public, didn't
work, I corrected any errors in my code, still not appearing, I tried
System.Serializable, nothing.
So what do I do now?
Here's the code I wrote to test it:
1.
2.
using UnityEngine;
using System.Collections;
3.
4.
[System.Serializable]
5.
6.
7.
8.
9.
10.
11.
void Start ()
12.
13.
14.
15.
16.
17.
void Update ()
18.
19.
20.
21.
}
}
22.
I wrote this while following a tutorial, neither variables appeared in the inspector.
c#inspector
more
asked Dec 09, 2012 at 12:58 AM
Cobra!
191 84 67 73
You have to post your script or else nobody will be able to help you.
Dec 09, 2012 at 01:22 AM Lockstep
The mouseXY is showing in the inspector to me, I'm not sure that the enum would
show up.
Dec 09, 2012 at 01:38 AM T27M
4 answers: sort voted first
1
The variables have to be public and part of the class, but not part of any method.
Make sure the script is compiling as any changes won't show if the new script
hasn't compiled.
1.
2.
using UnityEngine;
using System.Collections;
3.
4.
5.
6.
7.
8.
9.
10.
11.
void MyMethod()
{
int anotherNumber = 10;
12.
13.
14.
15.
16.
17.
So here the only ones that will show in the inspector and number and word. You
could also try re-adding the script, but I don't think that will be your problem.
more
answered Dec 09, 2012 at 01:21 AM
T27M
1.8k 36 38 46
I'm not sure if this actually is your problem, but is assume the int shows up but you
also want to see the enum. If that is the case, well, an enum is not a variable. It
rather defines a new type of variable. Like if you declare a variable as integer
means, that this variable can have values like {..., -1 , 0 , 1 ,...}. Tu use the enum
you have to declare a new variable as your enum:
1.
2.
3.
Then the someFancyName variable will show up in the inspector and you can
choose it to be either mouseX or mouseY. To use the variable inside of your script
you will have to use rotationAxis.mouseX to check for it. Like:
1.
2.
if(someFancyName == rotationAxis.mouseX){
3.
//do something
4.
5.
} else {
6.
7.
8.
9.
more
answered Dec 11, 2012 at 04:49 PM
Lockstep
1.9k 34 33 47
If you just edited the script, saved/recompiled, try using Assets>Refresh (Ctrl+R)
more
answered Nov 13, 2013 at 01:13 AM
Paulo Renaux
35 1 4
i dont have enough rep to vote, but +1 for u
May 13, 2014 at 03:00 PM Evorlor
I know this question's old, but another answer that I found solved my run-in with
this problem:
ketura
01
Your answer
[hide preview]
Topics:
c# x15212
inspector x1009
asked: Dec 09, 2012 at 12:58 AM
Seen: 16862 times
Last Updated: May 13, 2014 at 03:00 PM
Related Questions
Draw more EditorGUILayout components?
Multiple Cars not working
Distribute terrain in zones
Variable has not been assigned error
The name 'Joystick' does not denote a valid type ('not found')
How to control the exposure of public variables in the inspector pane based on a value
of another variable?
Problem using EditorGUILayout.ObjectField with custom type
How to control serialized variables over the inspector pane?
Input variable from Inspector?
Custom Inspector: Targets & GameObjects
about | faq | privacy policy | cookies | contact
Enterprise
Social Q&A