private void OnTerrainEntity(EntityAddedEvent evt) { TerrainEntity terEnt = (TerrainEntity)evt.AddedXmasEntity; TilePosition posinfo = (TilePosition)evt.AddedPosition; Point pos = posinfo.Point; var transform = Factory.CreateTile(terEnt, posinfo); transform.gameObject.AddComponent <TerrainInformation>(); var terinfo = transform.gameObject.GetComponent <TerrainInformation>(); terinfo.SetTerrain(terEnt); this.termap[terEnt] = transform; transform.renderer.sharedMaterial.SetTexture("_MainTex", TextureDictionary.GetTexture(terEnt.TextureType)); }
private void OnCardDrawn(CardDrawnEvent evt) { Transform cardobj = Factory.CreateCard(evt.DrawnCard); if (evt.DrawnCard.HasModule <GraphicsModule>()) { var graphics = evt.DrawnCard.Module <GraphicsModule>(); cardobj.renderer.material.SetTexture("_MainTex", TextureDictionary.GetTexture("cards_" + graphics.TextureId)); } cardOrder.AddLast(cardobj); cardobj.parent = playerCam.transform; currentHand.Add(evt.DrawnCard, cardobj); PositionHand(); cardobj.gameObject.SetActive(this.player.HasPriority); }
void DrawObjectPreview(GameObject o, BlockOrientation orientation) { if (o == null) { return; } GUILayout.BeginVertical(); Texture2D preview = GetPreviewForGameObject(o, false); GUILayout.BeginHorizontal(GUILayout.Width(100)); string name = o.name; if (name.Length >= 12) { name = name.Substring(0, 9); name += "..."; } GUILayout.Label(name); bool deleted = false; if (GUILayout.Button(new GUIContent(icons.GetTexture(TidyFileNames.ICON_DELETE_BLOCKPART), TidyMessages.BLOCK_EDITOR_BLOCKSET_REMOVE_VARIANT_TOOLTIP), GUILayout.Width(18), GUILayout.Height(18))) { workingBlock.Editor_RemoveFromBlockSet(orientation, o); //PREFAB /*if(destroyObject != null){ * Editor.DestroyImmediate(destroyObject,true); * }*/ SetBlockDirty(workingBlock); deleted = true; hasWorkingBlockChanged = true; if (!initialPreviewGenerated) { //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(), true); initialPreviewGenerated = true; } } GUILayout.EndHorizontal(); if (!deleted) { if (preview == null) { GUILayout.Button(o.name, GUILayout.Width(100), GUILayout.Height(100)); } else { GUILayout.Button(new GUIContent("", o.name), GUILayout.Width(100), GUILayout.Height(100)); GUI.DrawTexture(GUILayoutUtility.GetLastRect(), preview, ScaleMode.ScaleAndCrop, false); } } GUILayout.EndVertical(); }