Converting template to Vector3, 4 in string
hi, I tried to parse XML documentation.
but, this function gave me an error (NotSupportedExpetion : TypeConverter from UnityEngine.Vector4)
The role of this function is : (str.Equals("color") fontColor = TryParse(str.InnerText);
I do not know the problem .. Help
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Xml;
using UnityEngine;
...
public T TryParse<T>(string str)
{
if (str.Equals("-") || str.Equals("null")) return default(T);
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
if (typeof(T) == typeof(Vector3) || typeof(T) == typeof(Vector4))
{
string[] arr = str.Split('.', '(', ')', ',', ' ');
if (arr[0] == str)
Debug.LogError("Token Error!");
Vector4 vResult = Vector4.zero;
int nCount = 0;
for (int i = 0; i < arr.Length; ++i)
{
if (arr[i] == "") continue;
vResult[nCount++] = float.Parse(arr[i]);
}
return (T)converter.ConvertFrom(value: vResult);
}
return (T)converter.ConvertFromString(null, CultureInfo.InvariantCulture, str);
}
Comment
Your answer
Follow this Question
Related Questions
Adding Shader Graph to normal project 0 Answers
Cannot put a .tgz template in ProjectTemplates folder 0 Answers
How can I change template 0 Answers
Template object and script,GameObject scripts duplicated from a template game object 0 Answers
Is it possible to create NetworkBehavior derived template? 0 Answers