<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Batch Object Placer]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=847&amp;type=atom" />
	<updated>2018-05-30T11:12:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=847</id>
		<entry>
			<title type="html"><![CDATA[Re: Batch Object Placer]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3633#p3633" />
			<content type="html"><![CDATA[<p>That is awesome - thank you so much for the prompt reply! I&#039;ll get going and see what I can do.</p><p>Thanks again for such a great asset!</p>]]></content>
			<author>
				<name><![CDATA[stuarteve]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=738</uri>
			</author>
			<updated>2018-05-30T11:12:31Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3633#p3633</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Batch Object Placer]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3630#p3630" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Example:<br /></p><div class="codebox"><pre><code>using System.Collections.Generic;
using InfinityCode.RealWorldTerrain;
using UnityEditor;
using UnityEngine;

public class BatchPlacer: ScriptableWizard
{
    public GameObject prefab;
    public RealWorldTerrainContainer container;
    private List&lt;Vector2&gt; coords;

    [MenuItem(&quot;Window/Batch Placer&quot;)]
    static void CreateWizard()
    {
        BatchPlacer wizard = DisplayWizard(&quot;Batch Placer&quot;, typeof(BatchPlacer)) as BatchPlacer;
        wizard.container = FindObjectOfType&lt;RealWorldTerrainContainer&gt;();
    }

    void OnWizardCreate()
    {
        LoadCSVData();
        PlaceObjects();
    }

    private void PlaceObjects()
    {
        foreach (Vector2 coord in coords)
        {
            GameObject go = Instantiate(prefab);
            Vector3 pos;
            container.GetWorldPosition(coord, out pos);
            go.transform.position = pos;
        }
    }

    private void LoadCSVData()
    {
        // Here you load your CSV data

        GenerateDummyData(); // Generate dummy data
    }

    private void GenerateDummyData()
    {
        float tx = (float)container.leftLongitude;
        float ty = (float)container.topLatitude;
        float bx = (float)container.rightLongitude;
        float by = (float)container.bottomLatitude;

        int count = 20;
        coords = new List&lt;Vector2&gt;();
        for (int i = 0; i &lt; count; i++)
        {
            coords.Add(new Vector2(Random.Range(tx, bx), Random.Range(by, ty)));
        }
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-05-29T23:25:34Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3630#p3630</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Batch Object Placer]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3624#p3624" />
			<content type="html"><![CDATA[<p>Hi there</p><p>I would love to read in a CSV of coordinates and batch place a bunch of the objects there (without having to use the Object Placer to do each one individually). I have had a bit of a dig around in the code, but ended up getting a bit confused.</p><p>Is there any example script that could get me started on this?</p><p>Thanks for your help</p><p>Stuart</p>]]></content>
			<author>
				<name><![CDATA[stuarteve]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=738</uri>
			</author>
			<updated>2018-05-29T12:30:21Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3624#p3624</id>
		</entry>
</feed>
