示例#1
0
 void OnEnable()
 {
     if (Terrain.activeTerrain != null)
     {
         m_selectedMask = GaiaSplatPrototype.GetGaiaSplatPrototypes(Terrain.activeTerrain).Length;
     }
 }
示例#2
0
        void OnGUI()
        {
            //Set up the box style
            if (m_boxStyle == null)
            {
                m_boxStyle = new GUIStyle(GUI.skin.box);
                m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
                m_boxStyle.fontStyle        = FontStyle.Bold;
                m_boxStyle.alignment        = TextAnchor.UpperLeft;
            }

            //Setup the wrap style
            if (m_wrapStyle == null)
            {
                m_wrapStyle           = new GUIStyle(GUI.skin.label);
                m_wrapStyle.fontStyle = FontStyle.Normal;
                m_wrapStyle.wordWrap  = true;
            }

            //Text intro
            GUILayout.BeginVertical("Gaia Mask Exporter", m_boxStyle);
            GUILayout.Space(20);
            EditorGUILayout.LabelField("The Gaia splatmap exporter allows you to export texture splatmaps to use as masks.", m_wrapStyle);
            GUILayout.EndVertical();

            if (string.IsNullOrEmpty(m_maskName))
            {
                m_maskName = string.Format("Terrain-Splatmaps-{0:yyyyMMdd-HHmmss}", DateTime.Now);
            }
            m_maskName = EditorGUILayout.TextField(GetLabel("Mask Name"), m_maskName);

            List <GUIContent> textureNames = new List <GUIContent>();

            if (Terrain.activeTerrain != null)
            {
                var splatPrototypes = GaiaSplatPrototype.GetGaiaSplatPrototypes(Terrain.activeTerrain);
                for (int idx = 0; idx < splatPrototypes.Length; idx++)
                {
                    textureNames.Add(new GUIContent(splatPrototypes[idx].texture.name));
                }
            }
            textureNames.Add(new GUIContent("All"));
            m_selectedMask = EditorGUILayout.Popup(GetLabel("Selected Texture"), m_selectedMask, textureNames.ToArray());

            GUILayout.Space(5);

            EditorGUI.indentLevel++;
            if (DisplayButton(GetLabel("Export Selected Texture")))
            {
                ExportMask();
            }
            EditorGUI.indentLevel--;
        }