Had to convert JS script to C# - thanks Unity ... NOT!!!

hello there,

I am forced to convert a js script to c#, to have assets listed in the store, after Dec31…

Seems, a simple conversion on Convert unity javascript (unityscript) to C# does not work well - great :confused:

Can someone please explain, what´s wrong with the C# script-conversion?

With the old JS script, I was able to drag´n´drop terrians into “slots” on the inspector-window, to setup neighboring terrains.

At runtime, the script eliminates those ugly LOD seams (that are still present in the lates unity-version, congratz!) and it was ruinning fine.

With the converted C# script, I get no “slots” to drag the terrains into grrrr

What is going on with this? Is there some code-genius out there, that can help me out on this one?
I am more of an Artist, coding is not my domain…

the JS script:

#pragma strict

var terrainLeft : Terrain;
var terrainTop : Terrain;
var terrainRight : Terrain;
var terrainBottom : Terrain;
function Start()
{
var thisTerrain : Terrain = GetComponent(Terrain); thisTerrain.SetNeighbors( terrainLeft, terrainTop, terrainRight, terrainBottom);
}

the converted C#:

using UnityEngine;
using System.Collections;

public class TerrainStitcher : MonoBehaviour
{
    Terrain terrainLeft;
    Terrain terrainTop;
    Terrain terrainRight;
    Terrain terrainBottom;

    void Start()
    {
        Terrain thisTerrain = GetComponent<Terrain>();
        thisTerrain.SetNeighbors(terrainLeft, terrainTop, terrainRight, terrainBottom);
    }
}

Kind Regards !

add public or [SerializeField] to your variables. They are private right now, and therefore do not show up in the inspector.

4 Likes

awesome man, you rock !

adding “public” was key - now everythings works as it used to :slight_smile:

thanks a ton

No problem, you’re welcome. :slight_smile:

You’ll get used to c# with a bit of practice.