Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static readonly Regex _CopyWpsFromClipboardRegex = new Regex(@"(\(|\,)([-+]?[0-9]*\.?[0-9]+)");
- void CopyWaypointsToClipboard()
- {
- StringBuilder sBuilder = new StringBuilder();
- sBuilder.Append("Vector3[] waypoints = new[] { ");
- for (int i = 0; i < _src.wps.Count; ++i) {
- Vector3 wp = _src.wps[i];
- if (i > 0) sBuilder.Append(", ");
- sBuilder.Append(string.Format(
- "new Vector3({0}f,{1}f,{2}f)",
- wp.x.ToString(CultureInfo.InvariantCulture), wp.y.ToString(CultureInfo.InvariantCulture), wp.z.ToString(CultureInfo.InvariantCulture)
- ));
- }
- sBuilder.Append(" };");
- EditorGUIUtility.systemCopyBuffer = sBuilder.ToString();
- }
- void PasteWaypointsFromClipboard()
- {
- string s = EditorGUIUtility.systemCopyBuffer;
- MatchCollection matches = _CopyWpsFromClipboardRegex.Matches(s);
- if (matches.Count == 0) return;
- List<Vector3> wps = new List<Vector3>();
- for (int i = 0; i < matches.Count; i += 3) {
- wps.Add(new Vector3(
- float.Parse(matches[i].Groups[2].Value, CultureInfo.InvariantCulture),
- float.Parse(matches[i+1].Groups[2].Value, CultureInfo.InvariantCulture),
- float.Parse(matches[i+2].Groups[2].Value, CultureInfo.InvariantCulture)
- ));
- }
- // DOTweenPath methods, you should use your own code to fill your own waypoints here
- _src.wps = wps;
- _wpsList.list = _src.wps;
- }
Add Comment
Please, Sign In to add comment