Skip to content

Commit

Permalink
and another test, because my editor is not showing any wfs
Browse files Browse the repository at this point in the history
  • Loading branch information
bozmir committed Sep 19, 2024
1 parent 2f7aabd commit 6215e2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions Assets/Scripts/Layers/LayerTypes/GeoJSONLineLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void AddAndVisualizeFeature<T>(Feature feature, CoordinateSystem original
var newFeatureVisualisation = new FeatureLineVisualisations() { feature = feature };

// Create visual with random color if enabled
UpdateMaterialInstance();
lineRenderer3D.LineMaterial = GetMaterialInstance();

if (feature.Geometry is MultiLineString multiLineString)
{
Expand All @@ -66,20 +66,22 @@ public void AddAndVisualizeFeature<T>(Feature feature, CoordinateSystem original
SpawnedVisualisations.Add(newFeatureVisualisation);
}

private void UpdateMaterialInstance()
private Material GetMaterialInstance()
{
Material featureMaterialInstance;
// Create material with random color if randomize per feature is enabled
if (RandomizeColorPerFeature)
{
var randomColor = UnityEngine.Random.ColorHSV();
randomColor.a = LayerData.Color.a;

lineRenderer3D.LineMaterial.color = randomColor;
return;
featureMaterialInstance = new Material(lineRenderer3D.LineMaterial) { color = randomColor };
return featureMaterialInstance;
}

// Default to material with layer color
lineRenderer3D.LineMaterial.color = LayerData.Color;
featureMaterialInstance = new Material(lineRenderer3D.LineMaterial) { color = LayerData.Color };
return featureMaterialInstance;
}

/// <summary>
Expand Down
12 changes: 7 additions & 5 deletions Assets/Scripts/Layers/LayerTypes/GeoJSONPointLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void AddAndVisualizeFeature<T>(Feature feature, CoordinateSystem original
var newFeatureVisualisation = new FeaturePointVisualisations() { feature = feature };

// Create visual with random color if enabled
UpdateMaterialInstance();
pointRenderer3D.Material = GetMaterialInstance();

if (feature.Geometry is MultiPoint multiPoint)
{
Expand All @@ -63,20 +63,22 @@ public void AddAndVisualizeFeature<T>(Feature feature, CoordinateSystem original
SpawnedVisualisations.Add(newFeatureVisualisation);
}

private void UpdateMaterialInstance()
private Material GetMaterialInstance()
{
Material featureMaterialInstance;
// Create material with random color if randomize per feature is enabled
if (RandomizeColorPerFeature)
{
var randomColor = UnityEngine.Random.ColorHSV();
randomColor.a = LayerData.Color.a;

pointRenderer3D.Material.color = randomColor;
return;
featureMaterialInstance = new Material(pointRenderer3D.Material) { color = randomColor };
return featureMaterialInstance;
}

// Default to material with layer color
pointRenderer3D.Material.color = LayerData.Color;
featureMaterialInstance = new Material(pointRenderer3D.Material) { color = LayerData.Color };
return featureMaterialInstance;
}

/// <summary>
Expand Down

0 comments on commit 6215e2c

Please sign in to comment.