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; }
public BentoState(BentoState other, Vector3 pos, Vector3 scale, Vector3 rot) { position = other.position; localScale = other.localScale; rotation = other.rotation; if (pos.x != 0) { position.x = pos.x; } if (pos.y != 0) { position.y = pos.y; } }
public void Near(BentoState o, float t) { position = position * t + (o.position * (1 - t)); rotation = rotation * t + (o.rotation * (1 - t)); localScale = localScale * t + (o.localScale * (1 - t)); }