Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
error CS0136: A local variable named `ter' cannot be declared in this scope because it would give a different meaning to `ter', which is already used in a `child' scope to denote something else

case 2:
Terrain ter = (Terrain) terrain.GetComponent(typeof(Terrain));
if (ter == null) {
return;
}
TerrainData ter = ter.terrainData;
terrain.splatPrototypes = terData.splatPrototypes;
EditorGUILayout.Separator();
float mouseX;
EditorGUILayout.BeginHorizontal();
GUI.skin = terrain.guiSkin;
GUILayout.Label("Texture Slope");

What I have tried:

i try to change tre to some other name after i am getting more errors.
Posted
Updated 18-Aug-17 1:04am
Comments
Patrice T 18-Aug-17 6:56am    
How did you change the code?

The ter variable has been already declared with a different type. It looks like a typo in this line:
C#
TerrainData ter = ter.terrainData;
It should be
C#
TerrainData terData = ter.terrainData;
because you are using a terData variable afterwards.
 
Share this answer
 
Comments
Thomas Daniels 18-Aug-17 7:05am    
5.
Jochen Arndt 18-Aug-17 7:37am    
Thank you.

Looks like I was a little bit faster.
C#
Terrain ter = (Terrain)terrain.GetComponent(typeof(Terrain));
C#
TerrainData ter = ter.terrainData;

Type ter = ... says that a new variable of type Type (here Terrain or TerrainData) has to be created. But at TerrainData ter = ..., there already exists a variable of type ter in the same (or the outer) scope, so it can't do that.

Give the second 'ter' a different name: TerrainData data = ter.terrainData; for example. Then use the data variable wherever you need it.

You speak of getting "more errors" when you tried another name; if the above step is what you tried but it gives errors, then read the errors (maybe do a Google search if necessary) and figure out what's wrong with the code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900