- Home /
How do I use Serilization in a custom Javascript script?
I am learning about pathfinding and A* algorithms for 2D navigation. I am currently following a youtube tutorial but the guy uses C# for his scripts.
I am trying to mimic his code but for Javascript. One of the things he does in C# is use [System.Serilization]. (I think he is using a much older version of Unity).
I do the same thing but get errors. I think the updated version is [Serializable], but still get errors.
My code:
#pragma strict
[Serializable];
public var name: String;
public var tileVisualPrefab: GameObject;
My Error:
Assets/Scripts/TileType.js(3,2): BCE0005: Unknown identifier: 'Serializable'.
Assets/Scripts/TileType.js(3,1): BCE0034: Expressions in statements must only be executed for their side-effects.
How do I use serialization for custom javascript scripts?
You shouldn't have to serialize fields that are public. They will be visible in the Inspector as long as they are public. I also stand behind the following answer: http://answers.unity3d.com/answers/595628/view.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612130453im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
JS error when transferring from Unity 4 to 5 1 Answer
Help change the subject of this Script 1 Answer
Setting Scroll View Width GUILayout 1 Answer
OnTriggerEnter called only one time?!! 5 Answers