Example #1
0
    void OnInstalledObjectCreated(InstalledObject io_data)
    {
        // Create a visual GameObject to display the InstalledObject
        // Place that GameObject in the correct position
        // Add a SpriteRenderer
        // Registers the necessary callback functions,
        // and Stashes the relationship between the InstalledObject and its GameObject in the local map_InstalledObject2GameObject
        GameObject io_go = new GameObject();

        io_go.name = io_data.ObjectType + "_" + io_data.Tiles.First().X + "_" + io_data.Tiles.First().Y;
        io_go.transform.position = new Vector3(io_data.Tiles.First().X, io_data.Tiles.First().Y);
        io_go.transform.SetParent(this.transform, true);

        io_go.AddComponent <SpriteRenderer>().sprite = map_SpriteName2Sprite ["sp_IO_Trees"];

        io_data.RegisterCB_OnStateChanged(OnInstalledObjectStateChanged);

        map_InstalledObject2GameObject.Add(io_data, io_go);
    }