public void Create(BentoRenderPacket rp) { if (go != null) { return; } brp = rp; go = GameObject.CreatePrimitive(PrimitiveType.Cube); go.name = "command " + eventMessage; go.layer = 11; targetState = new BentoState(position, size, Vector3.zero); initialState = new BentoState(targetState, initialPos, Vector3.zero, Vector3.zero); currentState = new BentoState(initialState.position, initialState.localScale, initialState.rotation); go.transform.position = position; go.transform.localScale = size; material = new Material(brp.layout.material.shader); material.CopyPropertiesFromMaterial(brp.layout.material); material.SetTexture("_MainTex", rp.layout.background); go.GetComponent <Renderer>().material = material; GameObject go2 = new GameObject(); go2.layer = 11; go2.transform.parent = go.transform; Vector3 ls = go2.transform.localScale; go2.transform.localPosition = new Vector3(0, 0, -0.5f * size.z * ls.z); textMesh = go2.AddComponent <TextMesh>(); textMesh.alignment = TextAlignment.Center; textMesh.font = brp.layout.font; textMesh.anchor = TextAnchor.MiddleCenter; textMesh.text = text.get(); color.a = 1; textMesh.color = color; textMesh.fontSize = (int)brp.layout.fontSize; textMesh.characterSize = 0.3f; // Updated font MeshRenderer rend = go2.GetComponentInChildren <MeshRenderer>(); rend.material = textMesh.font.material; }
private void RenderAll(BentoRenderPacket rp, Rect r, Vector2 scale, float rotPhase, float timeScale) { /* pivot = new Vector2(r.xMin + r.width * 0.5f, r.yMin + r.height * 0.5f); * time += Time.deltaTime * timeScale; * * Matrix4x4 matrixBackup = GUI.matrix; * GUIUtility.ScaleAroundPivot(scale, pivot); * GUIUtility.RotateAroundPivot(rotAngle, pivot); * * rotAngle = Mathf.Sin(time + rotPhase)*rp.layout.wobbleAmplitude; * * if (background == null) * background = Util.createSolidTexture(rp.layout.backgroundColor); * * * * if (rp.layout.background != null) * GUI.DrawTexture(r, rp.layout.background); * * GUI.DrawTexture(r, background); * * * * // Decay * * GUI.Label(r, text, rp.layout.GetStyle(color)); * * if (r.Contains(Event.current.mousePosition) && hover<=1) * { * hover += Time.deltaTime*3; * if (hover > 1) hover = 1; * } * else * hover *= 0.95f; * * * if (GUI.Button(r, "", emptyStyle)) * { * //performSelect = this; * hover = 2; * if (rp.unityEvent != null) * { * BentoMenu.currentMessage = eventMessage; * rp.unityEvent.Invoke(); * } * } * GUI.matrix = matrixBackup; */ }
public void Render(BentoRenderPacket rp, Vector2 pos) { Vector2 dSize = new Vector2(0, childrenSize.y + rp.layout.spacing.y); if (childrenHorizontal) { dSize = new Vector2(childrenSize.x + rp.layout.spacing.x, 0); } Vector2 cpos = pos; foreach (BentoMenuItem2D bmi in children) { Rect r = getRect(cpos); float hoverScale = 1 + bmi.hover * rp.layout.hoverScale; // bmi.RenderAll(rp, r, Vector2.one*hoverScale, cpos.y*123.23453f, hoverScale*rp.layout.wobbleSpeed); bmi.Render(rp, cpos); cpos += dSize; } }