ResourceType Class |
Namespace: KSPDev.GUIUtils.TypeFormatters
The ResourceType type exposes the following members.
Name | Description | |
---|---|---|
ResourceType(Int32) | Constructs an object from a resource ID. | |
ResourceType(String) | Constructs an object from a resource nane. |
Name | Description | |
---|---|---|
Format(Int32) | Formats the value into a human friendly localized string. | |
Format(String) | Formats the value into a human friendly localized string. | |
ToString | Returns a string formatted as a human friendly resource name. (Overrides ObjectToString.) |
Name | Description | |
---|---|---|
(Int32 to ResourceType) | Coverts a resource ID value into a type object. | |
(String to ResourceType) | Coverts a resource name value into a type object. | |
(ResourceType to String) | Converts a type object into a resource name. | |
(ResourceType to Int32) | Converts a type object into a resource ID. |
Name | Description | |
---|---|---|
resourceId | A wrapped resource ID value. |
This class resolves the resource type/ID into it's full localized name.
Use it as a generic parameter when creating a LocalizableMessage descendants.
public class ResourceTypeDemo1 : PartModule { static readonly Message<ResourceType> msg1 = new Message<ResourceType>( "#TypeDemo_msg1", defaultTemplate: "Resource is: <<1>>"); void Show() { Debug.Log(msg1.Format(StockResourceNames.ElectricCharge)); // Prints: "Resource is: Electric Charge" Debug.Log(msg1.Format(PartResourceLibrary.ElectricityHashcode)); // Prints: "Resource is: Electric Charge" } }
Debug.Log(ResourceType.Format(StockResourceNames.ElectricCharge)); // Prints: "Resource is: Electric Charge" Debug.Log(ResourceType.Format(PartResourceLibrary.ElectricityHashcode)); // Prints: "Resource is: Electric Charge"