I'm working on a unity project and have added the Assembly definition to my project to keep things more organized. But now that I have added the Assembly Definition I can't assign any object at all from the inspector (no matter if it's a public or serialized field)
I have tried:
- To make the fields serialized
- Changed the file namespace
- Removed the namespace
- Changed that to the Root directory
- I also tried moving the file to another directory (directly under assets)
I also have added the Root namespaces at project settings>>editor.
And all the Assembly definitions have the same Root namespaces
Any suggestion would mean a lot to me, Thanks!
Inspector in normal state
Here is the inspector under Debug
The scripts are all under the Scripts folder
here is my class.
using IndritVaka.Assets.Script.Core;
using IndritVaka.Assets.Script.Model;
using TMPro;
using UnityEngine;
namespace IndritVaka.Assets.Script.IO
{
public class OutputManager: MonoBehaviour
{
public TextMeshProUGUI Date { get; set; }
public TextMeshProUGUI Imsak { get; set; }
public TextMeshProUGUI Fajr { get; set; }
public TextMeshProUGUI Sunrise { get; set; }
public TextMeshProUGUI Dhuhr { get; set; }
public TextMeshProUGUI Asr { get; set; }
public TextMeshProUGUI Sunset { get; set; }
public TextMeshProUGUI Isha { get; set; }
private void Awake()
{
TimingUtility.UPDATE_TIMINGS_UI = UpdateUi;
}
private void UpdateUi(Timings timings)
{
Date.text = timings.Date?.ToShortDateString();
Imsak.text = timings.Imsak?.ToShortTimeString();
Fajr.text = timings.Fajr?.ToShortTimeString();
Sunrise.text = timings.Sunrise?.ToShortTimeString();
Dhuhr.text = timings.Dhuhr?.ToShortTimeString();
Asr.text = timings.Asr?.ToShortTimeString();
Sunset.text = timings.Sunset?.ToShortTimeString();
Isha.text = timings.Isha?.ToShortTimeString();
}
private void OnDestroy()
{
TimingUtility.UPDATE_TIMINGS_UI -= UpdateUi;
}
}
}
CodePudding user response:
If you want to use auto properties and still want to expose them in the inspector, you can add the SerializeFieldAttribute
, like you always would, but add a field:
in front of it. This will add the attribute to the auto-generated backing field, resulting in it being serialized like it would if you wrote a full property.
[field: SerializeField]
public GameObject StuffToAssign { get; }
CodePudding user response:
The problem doesn't have to do at all with assembly. The problem was at get and set Removing them fixed the problem.
public TextMeshProUGUI Date { get; set; }
to
public TextMeshProUGUI Date;