Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DavidCP1 · Sep 17, 2018 at 06:07 AM · tilemapdynamic

Assistance Request: Dynamic Tilemapping

Search Engines have failed me in looking for the answers I need. My issue is a CS0122 Inaccessible due to protection. the objective is to have 1 line place all of the tiles on a tilemap based on data from a list.

 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Tilemaps;
 
 public class Game_Supplies : MonoBehaviour {
 
     //Serialization Inputs
     public Map_Data _MapData;
     public Tile_Sets _TileSets;
     public Object_Sets _ObjectSets;
     public Monster_Sets _MonsterSets;
     public NPC_Sets _NPCSets;
     
     //Tile List Sets
     public List<AreaData> AD = new List<AreaData>();
     public List<TileData> TD = new List<TileData>();
     
     //Tile Placement Sets
     public int _TCount;
     public int _TPlaced;
     public Vector3Int _Position;
     
     void Start(){
         GenBaseMap();
         TD.Add(new TileData(new Vector3Int(0, 0, 0), "_Ground", "_GroundField"));
     } 
     
     void GenBaseMap(){
         _TCount = TD.Count;
         for(_TPlaced = 0; _TPlaced < _TCount - 1; _TPlaced++){
             Vector3Int _TilePos = new Vector3Int(TD[_TPlaced].Data_TilePos.x, TD[_TPlaced].Data_TilePos.y, 0);
             string _LayerName = TD[_TPlaced].Data_TileLayer;
             string _TileType = TD[_TPlaced].Data_TileType;
             
             //needs modification for variance
             //_TileSets._TileLayer._Ground.SetTile(_TilePos, _TileSets._RuleTiles._Ground_Field);
             _TileSets._TileLayer(_LayerName).SetTile(_TilePos, _TileSets._RuleTiles._Ground_Field); //Error is in this line "TileLayer(_LayerName)".
             
             _TPlaced++;
         }
     }
     
     public class TileData {
         public Vector3Int Data_TilePos;// Store the location of the area center
         public string Data_TileType;     // tile type from "Rule_Tiles"
         public string Data_TileLayer;    // tile layer from "Tile_Layers"
         public TileData (Vector3Int _TPos, string _TType, string _TLayer) {
             Data_TilePos    = _TPos;
             Data_TileType    = _TType;
             Data_TileLayer    = _TLayer;
         }
     }
 
     [Serializable]
     public class Tile_Sets {
         public Rule_Tiles _RuleTiles;
         public Tile_Layer _TileLayer;
     }
     
     [Serializable]
     public class Rule_Tiles {
         public RuleTile _Ground_Field;
         public RuleTile _Ground_Forest;
         public RuleTile _Ground_Town_1;
         public RuleTile _Ground_Town_2;
         public RuleTile _Ground_Town_3;
         public RuleTile _Ground_Dun_1;
         public RuleTile _Ground_Dun_2;
         public RuleTile _Ground_Dun_3;
         public RuleTile _Ground_Boss;
         [Space(5)]
         public RuleTile _Wall_Field;
         public RuleTile _Wall_Forest;
         public RuleTile _Wall_Town_1;
         public RuleTile _Wall_Town_2;
         public RuleTile _Wall_Town_3;
         public RuleTile _Wall_Dun_1;
         public RuleTile _Wall_Dun_2;
         public RuleTile _Wall_Dun_3;
         public RuleTile _Wall_Boss;
     }
     
     [Serializable]
     public class Tile_Layer {
         public Tilemap _Barrier;
         public Tilemap _Ground;
         public Tilemap _GroundOverlay;
         public Tilemap _Obsticles;
         public Tilemap _ObsticlesOverlay;
     }
 }

I have attempted several other methods of trying to get the _TileLayer to locate an item from the Tile_Layer class that matches the string of the input but nothing I have tried is working. The line above it tested just fine when explicitly pointing to "_Ground", but I would prefer the line to be dynamic. the same would be true for "_GroundFields" in that same line, but I'm sure solving 1 issue will solve the other.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

88 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I am following a tilemap tutorial, however the UV layout is strange. How can I fix this? 0 Answers

Should I use built-in tilemaps or create my own tilemap system? 1 Answer

How to build a tilemap at runtime? 1 Answer

How can I make tiles move for a dynamic background 0 Answers

Stop player from pushing tilemap 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges