Currently I am trying to basically create a “tag system” in which one object could take two objects which both have the script “Object Tag” and send their names to a script that would decide whether the first object could be built on top of the second object. (Think like “Indoors vs Outdoors” from Prison Architect for example)
Here’s the code for a “String List Wrapper”:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class StringListWrapper
{
public string tagName;
public List<string> tagList;
}
The “tagName” refers to the tag of the structure the player is trying to build, wheras the “tagList” refers to the list of other objects that the player is allowed to build that structure on top of.
Here’s the code for the “Tag Checker”:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tags : MonoBehaviour {
public GameObject object1;
public GameObject object2;
public List<StringListWrapper> tags = new List<StringListWrapper>();
private void Start()
{
TagCheck(object1, object2);
}
public void TagCheck(GameObject gO1, GameObject gO2)
{
List<string> TagSet1 = gO1.GetComponent<ObjectTag>().tags;
List<string> TagSet2 = gO2.GetComponent<ObjectTag>().tags;
bool check = false;
for (int i = 0; i < TagSet1.Count; i++)
{
Debug.Log(tags*);*
}
}
}
What I am hoping to do is find an item in the “tags” list from the “Tags” script using a string name. But what I have found is that each item in the “tags” list is simply a “StringListWrapper”. (As you can see I did a debug of the “tags” index.
If you need anymore clarification just ask! Also, if you have a suggestion for a better way of reaching my eventual goal please, tell me.
Thank you,
— expat1999