How do I check if inspector variable has a value?
I'm trying to check if a script variable has a value assigned, not in the scene, but in the project. (When you click on the Project window, click the script, and it shows up in the Inspector).
vs.
My code to get the pictures above:
public class Sphere : MonoBehaviour {
public Mesh mesh;
}
Answer by fat_flying_pigs · Sep 16, 2015 at 04:58 AM
Ok, I found a solution - dunno if there is a better way. This seems kind of hacky...
The script's meta file without a mesh:
fileFormatVersion: 2
guid: b4862e4dbfff75e4a8b56fc2b7d7a029
timeCreated: 1442378139
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences:
- mesh: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
With a mesh attached:
- mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
I can read in the value using a C# StreamReader and it will work. Any alternative solutions would be appreciated.
Your answer
Follow this Question
Related Questions
Corrupted Project inspector bug. 1 Answer
Issues adding project to cloud build with invitation 0 Answers
Is there a maximum number of assets that I can put in a project without having problems to publish? 0 Answers
why cant i get into my project without the unity bug reporter stopping me 0 Answers
Unity teams trial 0 Answers