Exemple #1
0
    private void OnEnable()
    {
      valuePalletes = System.Enum.GetValues(typeof(SpriteColorRampPalettes));
      currentPallete = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);

      textureRamp = Resources.Load<Texture2D>("Textures/SpriteColorRamps");

      texturePallete = new Texture2D[5];

      InstantiateFigure(Random.Range(0, figures.Count));

      for (int i = 0; i < 5; ++i)
        texturePallete[i] = MakeTexture(32, 16, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPallete));
    }
Exemple #2
0
        private void OnEnable()
        {
            valuePalletes  = System.Enum.GetValues(typeof(SpriteColorRampPalettes));
            currentPallete = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);

            textureRamp = Resources.Load <Texture2D>("Textures/SpriteColorRamps");

            texturePallete = new Texture2D[5];

            InstantiateFigure(Random.Range(0, figures.Count));

            for (int i = 0; i < 5; ++i)
            {
                texturePallete[i] = MakeTexture(32, 16, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPallete));
            }
        }
Exemple #3
0
        private void OnGUI()
        {
            if (currentFigure != null && showGUI == true)
            {
                Vector3 screenPosition = Camera.main.WorldToScreenPoint(this.transform.position);

                float       width  = 260.0f;
                const float height = 85.0f;

                GUILayout.BeginArea(new Rect(screenPosition.x - (width * 0.5f), 20.0f, width, height), GUI.skin.box);
                {
                    GUILayout.BeginHorizontal();
                    {
                        currentFigureEnable = GUILayout.Toggle(currentFigureEnable, " Enable");

                        currentFigure.GetComponent <SpriteColorRamp>().enabled = currentFigureEnable;

                        GUI.enabled = currentFigureEnable;

                        GUILayout.Space(10.0f);

                        if (GUILayout.Button("<<") == true)
                        {
                            if (currentPallete > 0)
                            {
                                currentPallete--;
                            }
                            else
                            {
                                currentPallete = (SpriteColorRampPalettes)valuePalletes.Length - 1;
                            }

                            currentFigure.GetComponent <SpriteColorRamp>().palette = currentPallete;

                            for (int i = 0; i < 5; ++i)
                            {
                                texturePallete[i] = MakeTexture(32, 16, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPallete));
                            }
                        }

                        GUILayout.FlexibleSpace();

                        GUILayout.Label(currentPallete.ToString(), GUILayout.ExpandWidth(true));

                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button(">>") == true)
                        {
                            if (currentPallete < (SpriteColorRampPalettes)valuePalletes.Length - 1)
                            {
                                currentPallete++;
                            }
                            else
                            {
                                currentPallete = (SpriteColorRampPalettes)0;
                            }

                            currentFigure.GetComponent <SpriteColorRamp>().palette = currentPallete;

                            for (int i = 0; i < 5; ++i)
                            {
                                texturePallete[i] = MakeTexture(32, 16, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPallete));
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        for (int i = 0; i < 5; ++i)
                        {
                            GUILayout.Box(texturePallete[i]);
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUI.color = Color.white;

                    GUILayout.Space(5.0f);

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Strength", GUILayout.Width(65.0f));

                        currentStrenth = GUILayout.HorizontalSlider(currentStrenth, 0.0f, 1.0f);

                        currentFigure.GetComponent <SpriteColorRamp>().strength = currentStrenth;
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndArea();

                GUI.enabled = true;

                width = 200.0f;

                GUILayout.BeginArea(new Rect(screenPosition.x - (width * 0.5f), 535.0f, width, 30.0f), GUI.skin.box);
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (GUILayout.Button("<<") == true)
                        {
                            if (currentFigureIdx > 0)
                            {
                                InstantiateFigure(currentFigureIdx - 1);
                            }
                            else
                            {
                                InstantiateFigure(figures.Count - 1);
                            }
                        }

                        GUILayout.FlexibleSpace();

                        GUILayout.Label(currentFigure.name, GUILayout.ExpandWidth(true));

                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button(">>") == true)
                        {
                            if (currentFigureIdx < figures.Count - 1)
                            {
                                InstantiateFigure(currentFigureIdx + 1);
                            }
                            else
                            {
                                InstantiateFigure(0);
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndArea();
            }
        }
Exemple #4
0
    private void OnGUI()
    {
      if (currentFigure != null && showGUI == true)
      {
        Vector3 screenPosition = Camera.main.WorldToScreenPoint(this.transform.position);

        float width = 260.0f;
        const float height = 85.0f;

        GUILayout.BeginArea(new Rect(screenPosition.x - (width * 0.5f), 20.0f, width, height), GUI.skin.box);
        {
          GUILayout.BeginHorizontal();
          {
            currentFigureEnable = GUILayout.Toggle(currentFigureEnable, " Enable");

            currentFigure.GetComponent<SpriteColorRamp>().enabled = currentFigureEnable;

            GUI.enabled = currentFigureEnable;

            GUILayout.Space(10.0f);

            if (GUILayout.Button("<<") == true)
            {
              if (currentPallete > 0)
                currentPallete--;
              else
                currentPallete = (SpriteColorRampPalettes)valuePalletes.Length - 1;

              currentFigure.GetComponent<SpriteColorRamp>().palette = currentPallete;

              for (int i = 0; i < 5; ++i)
                texturePallete[i] = MakeTexture(32, 16, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPallete));
            }

            GUILayout.FlexibleSpace();

            GUILayout.Label(currentPallete.ToString(), GUILayout.ExpandWidth(true));

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(">>") == true)
            {
              if (currentPallete < (SpriteColorRampPalettes)valuePalletes.Length - 1)
                currentPallete++;
              else
                currentPallete = (SpriteColorRampPalettes)0;

              currentFigure.GetComponent<SpriteColorRamp>().palette = currentPallete;

              for (int i = 0; i < 5; ++i)
                texturePallete[i] = MakeTexture(32, 16, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPallete));
            }
          }
          GUILayout.EndHorizontal();

          GUILayout.BeginHorizontal();
          {
            for (int i = 0; i < 5; ++i)
              GUILayout.Box(texturePallete[i]);
          }
          GUILayout.EndHorizontal();

          GUI.color = Color.white;

          GUILayout.Space(5.0f);

          GUILayout.BeginHorizontal();
          {
            GUILayout.Label("Strength", GUILayout.Width(65.0f));

            currentStrenth = GUILayout.HorizontalSlider(currentStrenth, 0.0f, 1.0f);

            currentFigure.GetComponent<SpriteColorRamp>().strength = currentStrenth;
          }
          GUILayout.EndHorizontal();
        }
        GUILayout.EndArea();

        GUI.enabled = true;

        width = 200.0f;

        GUILayout.BeginArea(new Rect(screenPosition.x - (width * 0.5f), 535.0f, width, 30.0f), GUI.skin.box);
        {
          GUILayout.BeginHorizontal();
          {
            if (GUILayout.Button("<<") == true)
            {
              if (currentFigureIdx > 0)
                InstantiateFigure(currentFigureIdx - 1);
              else
                InstantiateFigure(figures.Count - 1);
            }

            GUILayout.FlexibleSpace();

            GUILayout.Label(currentFigure.name, GUILayout.ExpandWidth(true));

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(">>") == true)
            {
              if (currentFigureIdx < figures.Count - 1)
                InstantiateFigure(currentFigureIdx + 1);
              else
                InstantiateFigure(0);
            }
          }
          GUILayout.EndHorizontal();
        }
        GUILayout.EndArea();
      }
    }