private void Update() { if (!Singleton.Manager <ManPointer> .inst.DraggingItem && Input.GetMouseButtonDown(1)) { win = new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y - height, 400f, height); hasColor = false; try { var b = Singleton.Manager <ManPointer> .inst.targetVisible.block; module = b.GetComponent <ModuleProcedural>(); hasColor = b.GetComponent <ColorBlock.ModuleColor>(); x = module.Size.x; y = module.Size.y; z = module.Size.z; } catch (Exception e) { module = null; } visible = module; if (visible) { textures = (new string[] { "None" }).Concat(Directory.GetFiles(Path.Combine(ProceduralBlocksMod.AssetsFolder, "Textures"), "*.png")).Select(p => Path.GetFileName(p)).ToArray(); } } }
private void DoWindow(int id) { if (!module.block.IsAttached) { GUILayout.Label("X"); int.TryParse(GUILayout.TextField(x.ToString()), out x); x = Math.Min(64, x); GUILayout.Label("Y"); int.TryParse(GUILayout.TextField(y.ToString()), out y); y = Math.Min(64, y); GUILayout.Label("Z"); int.TryParse(GUILayout.TextField(z.ToString()), out z); z = Math.Min(64, z); var faces = module.Faces; foreach (var kv in module.Faces) { faces[kv.Key] = GUILayout.Toggle(kv.Value, kv.Key.ToString()); } module.Faces = faces; } GUILayout.Label(module.Texture); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.MaxHeight(200f)); foreach (var texture in textures) { if (GUILayout.Button(texture, new GUIStyle(GUI.skin.button) { richText = true, alignment = TextAnchor.MiddleLeft })) { module.Texture = texture; if (hasColor) { var c = module.block.GetComponent <ColorBlock.ModuleColor>(); c.Color = Color.white; c.active = module.Texture == ""; } } } GUILayout.EndScrollView(); if (module is ModuleProceduralSlicedMesh mpsm) { GUILayout.Label(mpsm.SlicedMeshName); scrollPos2 = GUILayout.BeginScrollView(scrollPos2, GUILayout.MaxHeight(200f)); foreach (var k in ModuleProceduralSlicedMesh.SlicedMeshes.Keys) { if (GUILayout.Button(k, new GUIStyle(GUI.skin.button) { richText = true, alignment = TextAnchor.MiddleLeft })) { mpsm.SlicedMeshName = k; } } GUILayout.EndScrollView(); } if (GUILayout.Button("Close")) { visible = false; module = null; } GUI.DragWindow(); }