当前位置: 首页>>代码示例>>C#>>正文


C# Block.GetName方法代码示例

本文整理汇总了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);
		}
	}
开发者ID:platformed,项目名称:Platformed-Game,代码行数:26,代码来源:BlockManager.cs

示例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);
		}
	}
开发者ID:platformed,项目名称:Platformed-Game,代码行数:29,代码来源:BlockManager.cs

示例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();
	}
开发者ID:platformed,项目名称:Platformed-Game,代码行数:13,代码来源:BlockIconManager.cs


注:本文中的Block.GetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。