Game dev
Game dev

Reputation: 324

Can't Assign Game Object from inspector on Unity

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:

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

enter image description here

Here is the inspector under Debug

enter image description here

The scripts are all under the Scripts folder

enter image description here

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;
            }
        }
    }

Upvotes: 1

Views: 1078

Answers (2)

Game dev
Game dev

Reputation: 324

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;

Upvotes: 0

Max Play
Max Play

Reputation: 4037

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; }

Upvotes: 2

Related Questions