No constructor found for randomstaff matching method signature [System.String].

30 views
Skip to first unread message

natanel...@gmail.com

unread,
Apr 6, 2018, 8:42:29 AM4/6/18
to Developer Support
hi,
i have been trying to make use of this tool in my project, but have been getting errors as i try to use it on objects which are not of MonoBehaviour.
i keep getting this error:

“ArgumentException: constructorArguments
Parameter name: No constructor found for randomstaff matching method signature [System.String]. ”

was wondering if this is cause i wasnt using MonoBehaviour, or from my coding. here is the code for the class i made to try the tool:

[System.Serializable]
public class randomstaff {
[SerializeField, Candlelight.PropertyBackingField(typeof(randomstaff),
“TSTR”)]
private string tstr = “”;
public string TSTR { get { return tstr; } set { if (value != tstr) tstr =
value; } }

[SerializeField, Candlelight.PropertyBackingField(typeof(randomstaff),
“TINT”)]
private int tint = 0;
public int TINT { get { return tint; } set { if (value != tint) tint =
value; } }

public randomstaff() {
tstr = “”;
tint = 0;
}
}

would really appropriate your help on that and really helpful tool
Natanel

Developer Support

unread,
Apr 9, 2018, 5:29:32 AM4/9/18
to Developer Support
Hi!

TLDR: Remove the typeof(randomstaff) from the attribute constructor and it should work.

The problem is just that you are using the wrong attribute constructor. The variant taking a type argument is used to specify a custom drawer. An example from the readme file:

If you have an existing property drawer you would like to use in conjunction
with this one, you simply need to specify the type associated with to the
property drawer in its CustomPropertyDrawer attribute as an additional argument.
If the type is a PropertyAttribute that takes arguments, specify them as
additional params:
    [SerializeField, Candlelight.PropertyBackingField(
        typeof(RangeAttribute), 0f, 1f // corresponds to [Range(0f, 1f)]
    )]
    private float m_Float;
    public float Float
    {
        get { return m_Float; }
        set { m_Float = value; }
    }

It is assumed that the property associated with the field is also defined on the same type, so you only need to pass the name if it does not following the _ or m_ convention. Also from the readme:

If your backing field does not have a "m_" or "_" prefix, or if its name
otherwise differs from the property to which it corresponds (including
differences in capitalization), you can supply the name of the property
manually:
    [SerializeField, Candlelight.PropertyBackingField("SomeInt")]
    private int m_Int = 0;
    public int SomeInt
    {
        get { return m_Int; }
        set { m_Int = value; }
    }
Reply all
Reply to author
Forward
0 new messages