コード例 #1
0
ファイル: GradientMakerEditor.cs プロジェクト: degonismi/Detr
    private static GradientWrapper CreateGradTexture()
    {
        // Create gradient object and assign generic starting colours
        GradientWrapper.ColorKey[] gck = new GradientWrapper.ColorKey[2];
        gck[0] = new GradientWrapper.ColorKey(Color.black, 0f);
        gck[1] = new GradientWrapper.ColorKey(Color.white, 1f);
        GradientWrapper.AlphaKey[] gak = new GradientWrapper.AlphaKey[2];
        gak[0] = new GradientWrapper.AlphaKey(1f, 0f);
        gak[1] = new GradientWrapper.AlphaKey(1f, 1f);
        GradientWrapper gw = new GradientWrapper();

        gw = GUIGradientField.GradientField("Gradient", gw);
        gw.SetKeys(gck, gak);
        return(gw);
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        var targetRender = target as MeshParticleRender;

        if (m_ParticleSystem != null)
        {
            ParticleSystemRenderer psRender = m_ParticleSystem.renderer as ParticleSystemRenderer;

            if (psRender.renderMode == ParticleSystemRenderMode.Mesh)
            {
                CopyFromParticleSystem();
            }
        }

        targetRender.Grad = GUIGradientField.GradientField("Color over Lifetime", targetRender.Grad);
    }
コード例 #3
0
ファイル: Painter.cs プロジェクト: cowtrix/Mad-Maps
        private void DrawSceneControls()
        {
            if (Event.current.type == EventType.MouseMove)
            {
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                UIBlockers.Clear();
            }
            Handles.BeginGUI();
            GUILayout.BeginArea(new Rect(0, 0, 240, Screen.height));

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField(EditorCellHelper.UseCPU() ? "Using CPU Painting" : "Using GPU Painting");
            EditorGUILayout.LabelField(string.Format("Grid Size: {0}", GridManager.GetGridSize().ToString("n2")));

            var offset = EditorPrefs.GetFloat("Painter_PlaneOffset", 0);

            offset = EditorGUILayout.FloatField("Plane Offset", offset);
            if (!Mathf.Approximately(PlaneOffset, offset))
            {
                PlaneOffset = offset;
                EditorPrefs.SetFloat("Painter_PlaneOffset", offset);
                _repaint = true;
            }

            MinValue = EditorGUILayout.FloatField("Min", MinValue);
            MaxValue = EditorGUILayout.FloatField("Max", MaxValue);
            Ramp     = GUIGradientField.GradientField("Ramp", Ramp);

            var opacity = EditorPrefs.GetFloat("Painter_Opacity", 0.5f);

            opacity = Mathf.Clamp01(EditorGUILayout.FloatField("Opacity", opacity));
            if (!Mathf.Approximately(Opacity, opacity))
            {
                Opacity = opacity;
                EditorPrefs.SetFloat("Painter_Opacity", opacity);
                _repaint = true;
            }

            EditorGUILayout.EndVertical();
            if (Event.current.type == EventType.Repaint)
            {
                // Update blocking rect
                var guiRect = GUILayoutUtility.GetLastRect();
                UIBlockers.Add(guiRect);
            }

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.BeginHorizontal();

            if (!PaintingEnabled)
            {
                EditorGUILayout.LabelField("Painting is Disabled");
            }

            GUI.enabled = PaintingEnabled;
            EditorGUILayout.LabelField(CurrentBrush != null ? CurrentBrush.GetType().Name : "Null");
            if (GUILayout.Button("...", EditorStyles.toolbarButton, GUILayout.Width(32)))
            {
                var menu = new GenericMenu();
                menu.AddItem(new GUIContent("Paint Brush"), true, () => CurrentBrush   = new DefaultBrush());
                menu.AddItem(new GUIContent("Blur Brush"), true, () => CurrentBrush    = new BlurBrush());
                menu.AddItem(new GUIContent("Cluster Brush"), true, () => CurrentBrush = new ClusterBrush());
                menu.AddItem(new GUIContent("Fill Brush"), true, () => CurrentBrush    = new FillBrush());
                menu.ShowAsContext();
            }

            EditorGUILayout.EndHorizontal();
            if (CurrentBrush != null)
            {
                CurrentBrush.DrawGUI();
            }
            EditorGUILayout.EndVertical();
            if (Event.current.type == EventType.Repaint)
            {
                // Update blocking rect
                var guiRect = GUILayoutUtility.GetLastRect();
                UIBlockers.Add(guiRect);
            }
            GUI.enabled = true;
            GUILayout.EndArea();

            Handles.EndGUI();

            // Save brush
            if (CurrentBrush != null)
            {
                EditorPrefs.SetString("Painter_LastBrushType", CurrentBrush.GetType().AssemblyQualifiedName);
                EditorPrefs.SetString("Painter_Brush_" + CurrentBrush.GetType().AssemblyQualifiedName, JsonUtility.ToJson(CurrentBrush));
            }
        }