Unity动态修改物体Tag

Tag可选列表已存在新tag(只需要修改)
this.transform.tag="newtag";
Tag可选列表不存在新tag(需要先修改列表,只有Editor可用)
using System.Linq;
using UnityEditor;
using UnityEngine;

string newtag="newtag";
#if UNITY_EDITOR
	if(!UnityEditorInternal.InternalEditorUtility.tags.Contains(newtag))
		UnityEditorInternal.InternalEditorUtility.AddTag(newtag);
#endif
this.transform.tag="newtag";
参考链接