public override void OnLevelLoaded(LoadMode mode) { if (!(mode == LoadMode.LoadGame || mode == LoadMode.NewGame)) { return; } try { LoadResources(); if (buildTool == null) { GameObject gameController = GameObject.FindWithTag("GameController"); buildTool = gameController.AddComponent<InGameTerrainTool>(); Texture2D tex = loadTextureFromAssembly("TerraformTool.builtin_brush_4.png", false); buildTool.m_atlas = terraform_atlas; buildTool.CreateButtons(); buildTool.m_brush = tex; buildTool.m_mode = InGameTerrainTool.Mode.Point; buildTool.enabled = false; GameObject.FindObjectOfType<ToolController>().Tools[0].enabled = true; } } catch (Exception e) { Debug.Log(e.ToString()); } }
public override void OnLevelLoaded(LoadMode mode) { if (!(mode == LoadMode.LoadGame || mode == LoadMode.NewGame)) { return; } try { LoadResources(); if (buildTool == null) { GameObject gameController = GameObject.FindWithTag("GameController"); buildTool = gameController.AddComponent <InGameTerrainTool>(); Texture2D tex = loadTextureFromAssembly("TerraformTool.builtin_brush_4.png", false); buildTool.m_atlas = terraform_atlas; buildTool.CreateButtons(); buildTool.m_brush = tex; buildTool.m_mode = InGameTerrainTool.Mode.Point; buildTool.enabled = false; GameObject.FindObjectOfType <ToolController>().Tools[0].enabled = true; } } catch (Exception e) { Debug.Log(e.ToString()); } }
public override void OnLevelLoaded(LoadMode mode) { if (!(mode == LoadMode.LoadGame || mode == LoadMode.NewGame)) { return; } try { GameObject gameController = GameObject.FindWithTag("GameController"); if (gameController) { Log.debug(gameController.ToString()); buildTool = gameController.AddComponent <InGameTerrainTool>(); Texture2D tex = new Texture2D(64, 64, TextureFormat.ARGB32, false); tex.filterMode = FilterMode.Bilinear; { // LoadTexture System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream textureStream = assembly.GetManifestResourceStream("TerraformTool.builtin_brush_4.png"); byte[] buf = new byte[textureStream.Length]; //declare arraysize textureStream.Read(buf, 0, buf.Length); // read from stream to byte array tex.LoadImage(buf); // Do not make read only ! tex.Apply(); } buildTool.m_brush = tex; UIView v = UIView.GetAView(); buildTool.m_mode = TerrainTool.Mode.Level; buildTool.m_brushSize = 25; buildTool.m_strength = 0.5f; buildTool.enabled = false; } } catch (Exception e) { Log.debug(e.ToString()); } CreateButtons(); }