protected override void OnPrefabInit() { base.OnPrefabInit(); Instance = this; //interceptNumberKeysForPriority = true; gameObject.AddComponent <InspectToolHoverTextCard>(); if (SelectTool.Instance == null || PrioritizeTool.Instance == null || DigTool.Instance == null) { return; } visualizer = new GameObject("CreateBlueprintVisualizer"); visualizer.SetActive(false); GameObject offsetObject = new GameObject(); SpriteRenderer spriteRenderer = offsetObject.AddComponent <SpriteRenderer>(); spriteRenderer.color = Color.white; spriteRenderer.sprite = InspectToolAssets.InspectToolCursor; offsetObject.transform.SetParent(visualizer.transform); offsetObject.transform.localPosition = new Vector3(0, Grid.HalfCellSizeInMeters); offsetObject.transform.localScale = new Vector3( Grid.CellSizeInMeters / (spriteRenderer.sprite.texture.width / spriteRenderer.sprite.pixelsPerUnit), Grid.CellSizeInMeters / (spriteRenderer.sprite.texture.height / spriteRenderer.sprite.pixelsPerUnit) ); offsetObject.SetLayerRecursively(LayerMask.NameToLayer("Overlay")); visualizer.transform.SetParent(transform); var self = Traverse.Create(this); var donorTool = Traverse.Create(SelectTool.Instance); //var donorTool2 = Traverse.Create(PrioritizeTool.Instance); var donorTool3 = Traverse.Create(DigTool.Instance); cursor = donorTool.Field <Texture2D>("cursor").Value; self.Field("boxCursor").SetValue(cursor); var digAreaVisualizer = donorTool3.Field <GameObject>("areaVisualizer").Value; var thisAreaVisualizer = Util.KInstantiate(digAreaVisualizer, gameObject, "inspectToolAreaVisualizer"); thisAreaVisualizer.SetActive(false); thisAreaVisualizer.transform.SetParent(transform); thisAreaVisualizer.GetComponent <SpriteRenderer>().color = Color.white; thisAreaVisualizer.GetComponent <SpriteRenderer>().material.color = Color.white; //visualizer = Util.KInstantiate(donorTool2.Field<GameObject>("visualizer").Value, gameObject, "InspectToolSprite"); //visualizer.SetActive(false); areaVisualizerSpriteRenderer = thisAreaVisualizer.GetComponent <SpriteRenderer>(); self.Field("areaVisualizer").SetValue(thisAreaVisualizer); self.Field("areaColour").SetValue(new Color32(255, 255, 255, 255)); self.Field("areaVisualizerTextPrefab").SetValue(donorTool3.Field <GameObject>("areaVisualizerTextPrefab").Value); }
public static void DestroyInstance() { Instance = null; }
internal static void Prefix() { InspectTool.DestroyInstance(); }