28

For now, since you're just beginning, text files are probably OK. There's a couple of concerns in your question that I'll address. Protecting the data isn't as crucial as you probably think. If your game is multiplayer, you'll have the data saved server-side anyways. If your game is single player, so what if players modify the data? If they break ...


19

You're looking for the SerializeField Attribute From the docs: Force Unity to serialize a private field. You will almost never need this. When Unity serializes your scripts, it will only serialize public fields. If in addition to that you also want Unity to serialize one of your private fields you can add the SerializeField attribute to the field. Your ...


13

What would the W3C do? The internet has had this problem. The World Wide Web Consortium noticed. It has a recommended standard solution since 1999: Scalable Vector Graphics (SVG). It's an XML-based file format specifically designed for storing 2D shapes. "Scalable-what?" Scalable Vector Graphics! Scalable: It's meant to scale smoothly to any size. Vector:...


12

When you send small messages, you have to be aware of the protocol overhead: Imagine you are sending a 10 byte message. A TCP header is 24 bytes, an UDP header is 8 bytes. Assuming you use UDP, you have 18 bytes in total. But you also have the IP header, which is at least an additional 20 bytes in IPv4 or 40 bytes in IPv6. That's 38 bytes in total when ...


11

The reason that you can't change any of the values is because the Point struct isn't a Vector2 data type. A Vector2 contains 2 floats where Point has 2 ints, meaning that the types are incompatible. The other problem was that you couldn't get the data from the struct in the way that Unity's inspector code wants you too. Point.cs [System.Serializable] ...


6

I think you have two problems: Non-symmetric control points Initially you start with equal distances between p0 to p1 and p1 to p2. If the tolerance angle between the line segments is not met, you move p1 and p2 forward, but keep p0 where it was. This increases the distance between p0 to p1 while keeping the distance between p1 to p2 the same. When you ...


5

I think the obj file format is what you need. OBJ is pretty commonly used in 3D graphics, and it's a text file. You will need to walk through your mesh properties and write your own file. Then you'll be able to load and display it.


5

The [SerializeField] attribute instructs Unity to serialize the field regardless of the accesibility. All three fields below gets serialized and shows up on inspector: [SerializeField] private int _foo; [SerializeField] protected int _bar; [SerializeField] internal int _baz; Note that, in order to expose custom types in Inspector, you need to ...


4

As with so many things, the answer is "Depends" Do you need to load a couple of hundred megs of data quickly? Are you streaming data in as the player traverses the level? Are you reading from optical media? If the answer is "yes", then pre-packed resource streaming is for you. If you're just making pong. It's not really a big issue, loading flat ...


4

To get a smoother intersection of two paths, you could scale them up before intersection and scale them down after. I don't know if it's a good solution, but it worked well for me. It's also fast. In my example, I intersect a rounded path with a pattern I created (stripes). It looks good even when scaled. Here my code: Path mypath=new Path(<...


4

Your code contains a misleading comment: dstPath.quadTo(p2[0] , p2[1], p3[0], p3[1]); //create a curve to the third point through the second A quadratic bezier curve does not go through the second point. If you want to go through the second point you need a different type of curve, such as a hermite curve. You may be able to convert the hermite curves into ...


4

Unique identifiers are a good option. However, they don't need to be used in game, only when writing and then reading the data from a save. Hopefully you'd already have some way to differentiating between entities you can use, otherwise you can make something up (typically an int or long) Pick a unique ID for each entity, then proceed to writing the ...


3

The word Game Data can mean many things, for example Gamestate Configuration files Maps, textures, sounds, scripts, animation data, ... Localisation GUI layout data more i didn't think of For each category you can take another approach. For example you could use SQLite for Localisation stuff, binary for Maps, textures, sounds and so on. For configuration ...


3

Send logical data, not presentation. Most games will never send graphics or textures to other systems during gameplay. Each system should already have all the resources it needs to render the events; you just send information about which events have taken place.


3

I'm not sure if it's a good idea. This sounds like a perfectly good idea for a start. Apparently you plan on dumping directly your struct in binary data files: as Evan said, this is a commonly used approach. It's compact and efficient, but it has quite a few pitfalls: It's hard for a human being to read them. It's hard to find differences between versions ...


3

First off, you misunderstand how UDP works: Lets say you send a 2500 byte packet. It will get fragmented into two separate packets and then reassembled transparently on the other end. UDP datagrams are atomic. An UDP datagram will not be split up into packets. I recommend sending the data in small atomic datagrams. The overhead is typically 28 bytes, ...


3

Look at polygon interpolation (http://en.wikipedia.org/wiki/Polynomial_interpolation) Basically, you take n equispaced nodes (optimal interpolation is not equispaced, but for your case it should be good enough and easy to implement) You end up with a polygon of order n which decreases the error between your curve if (<-- big if) your line is smooth ...


3

Unity internally uses ogg vorbis for audio - whenever you drop an mp3 into your Unity project, the editor converts it to vorbis and uses that. Importantly, this means Unity can natively decode ogg vorbis audio files at runtime including streaming them via WWW. So, rather than essentially creating a new binary audio format (both ogg and mp3 do some very ...


2

Message pack is a great alternative too! (http://msgpack.org)


2

Google FlatBuffers is an efficient cross platform serialization library for C++, with support for Java and Go. It was created at Google specifically for game development and other performance-critical applications. It is available as open source under the Apache license, v2.


2

I have written a command line OBJ manipulation tool myself, which has the representation preservation as one design goal. It does not offer an intermediate form of the model (so it does not "load" it), but rather reads the file line by line and dumps the same line back, unless the requested operation such as scaling or centering needs manipulating the data. ...


2

If the point of the conversion is for storage only, and when you render it back on the screen you need it to be smooth, then the highest fidelity storage you can get, while still minimizing the total storage required to persist a given curve might be to actually store the attributes of the circle (or an arc, rather) and re-draw it on demand. Origin. Radius. ...


2

Is there a reason for going for curves as opposed to straight lines? Straight lines are simpler to work with, and can be rendered efficiently in hardware. The other approach worth considering is to store a couple of bits per pixel, stating if it's inside, outside or on the outline of the shape. This should compress well, and might be more efficient than ...


2

The problem with what you're trying to do is that Unity has to recompile your scripts and reload the DLLs every time you make a change, which wipes out all of your non-serialized values, including static fields. Serialization isn't just how they save your scenes and prefabs to disk, it's also how they restore the editor's state every time you compile. Every ...


2

You are trying to write code to deserialize your xml file. The Xml deserialization in Xna is automatic so you do not need your XmlManager class at all. Add your Xml file (myXmlFile.xml) to your content project just like you would a texture or model. This will allow the build process to convert it from xml to serialized xnb. Now your project is aware of ...


2

to remove class information, use fileJson.setTypeName(null) to display all infomation including default value (in your case "false" is default of boolean), use fileJson.setUsePrototypes(false); see more in documents


2

The strings are on initial value because you never set data.payload.option to anything. You set up a variable Payload2 data2, but you never assign it in any way to anything of the variable data. Try replacing data2.option = new Option () { with data.payload.option = new Option () { By the way: I have no idea what the line string dataValue =data+ data2....


Only top voted, non community-wiki answers of a minimum length are eligible