- Home /
can't see property of asset created from scriptable object
created simple Scriptable object. and I wanted to create an asset from it. when i create it I cant access the properties of the the asset.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
  
 [CreateAssetMenu]
 public class Houe : ScriptableObject
 {
     public string Name { get; set; }
     public int Price { get; set; }
  
     public int bedrooms { get; set; }
  
     public bool havePool { get; set; }
  
 }
 
but when I created Villa asset i can't access the public properties in the inspector and change them.
Answer by yummy81 · Apr 19, 2020 at 04:44 PM
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 [CreateAssetMenu]
 public class Houe : ScriptableObject
 {
     [SerializeField] string name;
     public string Name => name;
 
     [SerializeField] int price;
     public int Price => price;
 
     [SerializeField] int bedrooms;
     public int Bedrooms => bedrooms;
 
     [SerializeField] bool havePool;
     public bool HavePool => havePool;
 
 }
or you can do it that way:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 [CreateAssetMenu]
 public class Houe : ScriptableObject
 {
     [field: SerializeField]
     public string Name { get; set; }
     
     [field: SerializeField]
     public int Price { get; set; }
 
     [field: SerializeField]
     public int bedrooms { get; set; }
 
     [field: SerializeField]
     public bool havePool { get; set; }
 
 }
It worked. but couple of question why the getter and setter cause problems?
Answer by logicandchaos · Apr 19, 2020 at 04:19 PM
I'm not sure but I would just just variables instead of properties if you are having issues with them.
Your answer
 
 
             Follow this Question
Related Questions
Unity inspector field overlap with eachother 1 Answer
Can a ScriptableObject contain a List of ScriptableObjects? 2 Answers
Why doesn't my ScriptableObject save using a custom EditorWindow? 3 Answers
Show multiple attached scripts variables in one script in the inspector 0 Answers
Referencing / linking a .asset / .prefab file in another .asset / .prefab file programmatically. 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                