本文整理汇总了C#中Block.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# Block.GetName方法的具体用法?C# Block.GetName怎么用?C# Block.GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.GetName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: RenderIcon
void RenderIcon(Block block) {
iconCamera.Render();
RenderTexture.active = iconTexture;
Texture2D icon = new Texture2D(iconTexture.width, iconTexture.height);
icon.alphaIsTransparency = true;
icon.ReadPixels(new Rect(0, 0, iconTexture.width, iconTexture.height), 0, 0);
icon.Apply();
File.WriteAllBytes(Application.dataPath + "/Resources/Block Icons/" + block.GetName() + ".png", icon.EncodeToPNG());
block.DestroyBlock();
}