static void Main() { var label = new Label { Text = "Label", Location = new Point(20, 50) }; var container = new GradientContainer { Size = new Size(200, 200), Location = new Point(0, 0), Controls = { label } }; Form form = new Form { Controls = { container }, Size = new Size(300, 300) }; Application.Run(form); }
public void PrepareGradient() { //terrible hack to make gradient editor appear gradCont = new GameObject("_temp_gradient_container").AddComponent <GradientContainer>(); serialColGradObj = new SerializedObject(gradCont); serialColGrad = serialColGradObj.FindProperty("grad"); GradientColorKey[] gck = new GradientColorKey[2]; gck[0].color = Color.black; gck[0].time = 0.0f; gck[1].color = Color.white; gck[1].time = 1.0f; GradientAlphaKey[] gak = new GradientAlphaKey[2]; gak[0].alpha = 1.0f; gak[0].time = 0.0f; gak[1].alpha = 1.0f; gak[1].time = 1.0f; gradCont.grad.SetKeys(gck, gak); EditorUtility.SetDirty(gradCont); }