rabidus-test/Assets/Plugins/QFSW/Quantum Console/Source/Scripts/Parsing/Parsers/ComponentParser.cs

23 lines
604 B
C#
Raw Normal View History

2023-08-22 15:41:12 +03:00
using QFSW.QC.Utilities;
using System;
using UnityEngine;
namespace QFSW.QC.Parsers
{
public class ComponentParser : PolymorphicQcParser<Component>
{
public override Component Parse(string value, Type type)
{
GameObject obj = ParseRecursive<GameObject>(value);
Component objComponent = obj.GetComponent(type);
if (!objComponent)
{
throw new ParserInputException($"No component on the object '{value}' of type {type.GetDisplayName()} existed.");
}
return objComponent;
}
}
}