【问题标题】:How to access gradient editor in Unity3D?如何在 Unity3D 中访问渐变编辑器?
【发布时间】:2015-01-27 01:33:26
【问题描述】:

我在 Unity 手册中搜索以了解他们对渐变效果的了解,结果发现:

这里是链接:

http://docs.unity3d.com/Manual/EditingValueProperties.html

但是,我在 Unity 中的任何地方都找不到这个编辑器。我想用它来为我的游戏背景应用渐变。存在吗!?

【问题讨论】:

  • 我只在粒子系统组件中管理颜色、编辑“生命周期颜色”和“速度颜色”时看到了渐变编辑器窗口。谷歌搜索 unity3d create gradient 似乎建议您可以通过代码创建渐变,否则可以尝试导入自己的纹理。
  • 我投票决定将此问题作为离题结束,因为它与编程无关。试试 gamedev.stackexchange.com 或 Unity Answers。

标签: colors background unity3d


【解决方案1】:

您无权随意使用颜色选择器或渐变编辑器。出于制作背景的目的,您有多种选择,

  1. 从编辑器更改Camera background color
  2. 使用Skybox,你也可以make your own skybox
  3. 如果您的游戏视野有限,请使用带有custom material 的飞机。

【讨论】:

    【解决方案2】:

    也许这个脚本展示了如何使用渐变。您需要将此脚本添加到场景中的GameObject 之一。而你的Camera 的标签是MainCamera

    此代码基于this

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    
    public class GradientHandler : MonoBehaviour {
    
        public Camera camera;
        public Gradient gradient;
        // Use this for initialization
        void Start () {
            camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>() as Camera; //Gets Camera script from MainCamera object(Object's tag is MainCamera).
            GradientColorKey[] colorKey = new GradientColorKey[2];
            GradientAlphaKey[] alphaKey = new GradientAlphaKey[2];
            // Populate the color keys at the relative time 0 and 1 (0 and 100%)
            colorKey[0].color = Color.red;
            colorKey[0].time = 0.0f;
            colorKey[1].color = Color.blue;
            colorKey[1].time = 1.0f;
            // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
            alphaKey[0].alpha = 1.0f;
            alphaKey[0].time = 0.0f;
            alphaKey[1].alpha = 0.0f;
            alphaKey[1].time = 1.0f;
            gradient.SetKeys(colorKey, alphaKey);
        }
    
        // Update is called once per frame
        void Update () {
            Debug.Log ("Time: "+Time.deltaTime);
            camera.backgroundColor = gradient.Evaluate(Time.time%1);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-19
      • 2011-06-05
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 2023-03-29
      相关资源
      最近更新 更多