- Home /
Serialize the text
Greetings fellows! Is it possible to serialize the string value? Currently, I have a script working all right if 2 variables are integer or float, but it shows error, once I change data type to string.
using UnityEngine;
using System.Collections;
public class serializeee : MonoBehaviour {
public string text1 = "This is text 1";
public string text2 = "This is text 2";
void Update () {
}
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
if (stream.isWriting) {
text1 = text2;
stream.Serialize(ref text1);
} else {
stream.Serialize(ref text1);
text2 = text1;
}
}
}
Could you please suggest what is wrong and how to fix it?
Thanks!
Answer by frarees · Oct 28, 2014 at 12:05 PM
Supported types are: bool, char, short, int, float, Quaternion, Vector3 and NetworkPlayer.
Answer by Fewpwew130 · Oct 28, 2014 at 12:08 PM
Thanks, but it is said here: http://docs.unity3d.com/Manual/script-Serialization.html that "primitive data types (int, float, double, bool, string, etc.)" can be serialized. Or am I wrong?
sorry, I am new to this. Then how would I serialize my script?
Your answer
Follow this Question
Related Questions
Looking for a javascript unity implementation of FromCharCode? 0 Answers
Separating two strings 1 Answer
Need help (String) 2 Answers
Reading integer value from specified character(s) on text line? 2 Answers