コード例 #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
ファイル: GradientMakerEditor.cs プロジェクト: degonismi/Detr
    private void OnGUI()
    {
        Grad = GUIGradientField.GradientField("Gradient", Grad);

        // Gradient Options
        _invertGradient = EditorGUILayout.Toggle("Invert Gradient", _invertGradient);
        gradType        = (GradType)EditorGUILayout.EnumPopup("Gradient Type", gradType);

        // Gradient Falloff
        if (gradType == GradType.Radial)
        {
            EditorGUILayout.BeginHorizontal();
            string falloff = EditorGUILayout.TextField("Falloff", _radialGradientFalloff.ToString());
            float.TryParse(falloff, out _radialGradientFalloff);
            GUILayout.EndHorizontal();
            _radialGradientFalloff = GUILayout.HorizontalSlider(_radialGradientFalloff, 0f, 100f);
        }

        // Output filename
        _fileName = EditorGUILayout.TextField("Output Filename", _fileName);

        // Gradient output size/aspect
        EditorGUILayout.BeginHorizontal();
        if (_fixedAspect)
        {
            EditorGUILayout.PrefixLabel("Gradient Size");
        }
        else
        {
            EditorGUILayout.PrefixLabel("Gradient Width");
        }
        string gradSizeX = EditorGUILayout.TextField(_gradientSizeX.ToString());

        int.TryParse(gradSizeX, out _gradientSizeX);
        EditorGUILayout.PrefixLabel("px");
        EditorGUILayout.EndHorizontal();

        if (_fixedAspect)
        {
            _gradientSizeY = _gradientSizeX;
        }
        else
        {
            string gradSizeY = EditorGUILayout.TextField("Gradient Height", _gradientSizeY.ToString());
            int.TryParse(gradSizeY, out _gradientSizeY);
        }

        // Set parammeters of gradient preview area
        GUILayoutOption[] guioptions = new GUILayoutOption[2];
        guioptions[0] = GUILayout.Height(Mathf.Clamp(_gradientSizeX, 4, 256));
        guioptions[1] = GUILayout.Width(Mathf.Clamp(_gradientSizeY, 4, 256));

        GUIStyle previewStyle = new GUIStyle();

        previewStyle.alignment = TextAnchor.MiddleCenter;

        // Load checker pattern for preview area

        string path = null;

        if (checker == null || checker.width != _gradientSizeX || checker.height != _gradientSizeY)
        {
            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                path = Application.dataPath + "/GradientMaker/";
            }
            else if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                path = Application.dataPath + "\\GradientMaker\\";
            }

            byte[] rawChecker = File.ReadAllBytes(path + "Checker.png");
            checker = new Texture2D(_gradientSizeX, _gradientSizeY);
            checker.LoadImage(rawChecker);
        }

        // Draw prewiew area
        GUILayout.BeginHorizontal(checker, previewStyle, guioptions);
        GUILayout.Label(outTexture, guioptions);
        GUILayout.EndHorizontal();

        _overWriteExisting = EditorGUILayout.ToggleLeft("Overwrite existing", _overWriteExisting);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Save Gradient"))
        {
            InitProcessGradient(false);
        }
        GUILayout.EndHorizontal();

        // Update preview if nessisary
        if (GUI.changed)
        {
            Undo.RecordObject(this, "Gradient Changed");
            InitProcessGradient(true);
            EditorUtility.SetDirty(this);
        }
    }
コード例 #4
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));
            }
        }