本文整理汇总了C#中Block.GetDisplayName方法的典型用法代码示例。如果您正苦于以下问题:C# Block.GetDisplayName方法的具体用法?C# Block.GetDisplayName怎么用?C# Block.GetDisplayName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.GetDisplayName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddBlockButton
/// <summary>
/// Adds the block buttons to the block library
/// </summary>
void AddBlockButton(Block block, BlockCategory category) {
//Ignore air
if (block.GetName() != "Air") {
//Instatiate object
GameObject button = Instantiate(blockButton) as GameObject;
button.transform.SetParent(blockLibrary);
button.name = block.GetDisplayName() + " Button";
//Set button onClick
Button b = button.GetComponent<Button>();
string n = block.GetName();
b.onClick.AddListener(() => DesignManager.instance.SetToolBlock(n));
//Set icon
Image icon = button.transform.GetChild(0).GetComponent<Image>();
Texture2D texture = Resources.Load("Block Icons/" + block.GetName()) as Texture2D;
if (texture == null) {
texture = Resources.Load("Block Icons/Error") as Texture2D;
}
icon.overrideSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
//Add to list
blockCategories.Add(category);
blockButtons.Add(button);
}
}
示例2: AddVRBlockButton
void AddVRBlockButton(Block block, BlockCategory category) {
//Ignore air
if (block.GetName() != "Air") {
//Instatiate object
GameObject button = Instantiate(vrBlockButton) as GameObject;
button.transform.SetParent(vrBlockLibrary);
button.transform.localScale = Vector3.one;//new Vector3(1f / 100f, 1f / 100f, 1f / 100f);
button.name = block.GetDisplayName() + " Button";
//Set button onClick
VRBlockButton b = button.GetComponent<VRBlockButton>();
b.block = block;
//Set icon
Image icon = button.transform.GetChild(0).GetComponent<Image>();
Texture2D texture = Resources.Load("Block Icons/" + block.GetName()) as Texture2D;
if (texture == null) {
texture = Resources.Load("Block Icons/Error") as Texture2D;
}
icon.overrideSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
//Add to list
blockCategories.Add(category);
blockButtons.Add(button);
}
}