- Home /
Convert a Java open source project to Unity C#?
I have found a really interesting Java project here:
http://gamedev.tutsplus.com/tutorials/implementation/coding-destructible-pixel-terrain/
and I would love to be able to mess around with this is unity - but problem is of course its written in Java, and has many differences from unity C# (and more so from unityscript) so I am wondering if there is any "best method" of getting from java to C#, and because it rely's on some java methods that work different in C#, is it going to cause a big headache? What are your thoughts on this you unity pro's? Can it be done?
Some parts don't seem too far from unity's C#:
boolean isPixelSolid(int x, int y) {
if (x > 0 && x < img.width && y > 0 && y < img.height)
return img.pixels[x + y * img.width] != color(0,0);
return false; // border is not solid
}
Oh and I am not opposed to alternative suggestions to get to the same effect in unity, the Destruction of pixels like demonstrated on that webpage...
Answer by DESTRUKTORR · Sep 03, 2013 at 12:07 AM
There's actually not that many differences between java and C#... The syntax is almost exactly the same. The biggest differences are the built-in systems (Java has a much better selection of built-in collections classes than C# does, for example).
The best method for this would probably just be to copy/paste each class into a new C# class in Unity and just start going through them, correcting errors. There will likely be a lot, but it shouldn't take too long, considering you're converting languages, lol.
$$anonymous$$eep in $$anonymous$$d Java is not Javascript.
Yes, I really felt like it seems more like C# (this is my first time working with Java at all) and that's pretty much the only reason I had thought it might be do-able to convert.
Anyway I have worked out some kinks with a couple scripts, but its gonna take a lot of time to convert this whole project - especially considering its use of some java techniques that work differently in unity, like for instance it creates a var for a "Pimage"... which is what I am trying to figure out right now... I guess this is built into "processing"
Your answer
Follow this Question
Related Questions
Converting Script from Java to C# 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
c# to compile xml string as code during runtime 1 Answer
how to make Doors or something similar with joints 2 Answers