- Home /
How to expose a struct type variable from dll, which is not declared [Serializable]
In my project I'm using a dll that contains a public struct like the following:
public struct DLLStructName { public float SomeValue; }
It is not declared [Serializable]
.
Now I'm declaring: public class MyClass { public DLLStructName structObject; }
What I would like to achieve is that in the editor property view I can modify DLLStructName.SomeValue
.
What is the best way to achieve this?
if the class was a $$anonymous$$onoBehaviour, you could use the ISerializationCallbackReceiver interface to serialize into another serialized field.
https://docs.unity3d.com/ScriptReference/ISerializationCallbackReceiver.html As far as I know, the equivalent NET ISerializable interface does the same, but for SerialiableAttribute'ed classes that you don't have.
I'd google that.
Answer by seanybaby2 · Oct 01, 2018 at 09:22 PM
If you put System.Serializable and make the values public the struct is exposed, other then that. You would probably have to make an editor script to expose them.
[System.Serializable]
public struct Attachments
{
public Transform scopeModPos;
public Transform muzzleModPos;
[HideInInspector]
public WeaponAttachment scopeMod;
[HideInInspector]
public WeaponAttachment muzzleMod;
}
public Attachments attachmentConnectionLocations;
Your answer
Follow this Question
Related Questions
Should EditorGUILayout.PropertyField work with serializable classes? 1 Answer
How to force close Popup Window? 1 Answer
Display changes in the editor made to a prefab 0 Answers
OnSceneGUI render projection onto object surface 1 Answer
GUI Text Field keeps resetting when trying to type in Text 1 Answer