Пример #1
0
 /// <summary>
 /// 根据Texture获取elem类型
 /// </summary>
 /// <returns>The element type.</returns>
 /// <param name="vTexture">V texture.</param>
 TileMapElemType EstimateElemType(Texture2D vTexture)
 {
     for (int i = 0; i < (int)TileMapElemType.None; i++)
     {
         _tempElemType = (TileMapElemType)i;
         if (vTexture.name.Contains(_tempElemType.ToString().ToLower()))
         {
             return(_tempElemType);
         }
     }
     return(TileMapElemType.None);
 }
Пример #2
0
    void OnEnable()
    {
        //get texture from local
        if (m_SelectTexture == null)
        {
            string texturePath = EditorPrefs.GetString("TileMapWindow_SelectTexture_Path", "");
            if (!string.IsNullOrEmpty(texturePath))
            {
                m_SelectTexture = (Texture2D)AssetDatabase.LoadMainAssetAtPath(texturePath);
            }
        }

        m_SelectElemType = EstimateElemType(m_SelectTexture);
    }
Пример #3
0
    // Use this for initialization
    void OnGUI()
    {
        //Assign Texture
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Texture Elem");
        _tempTexture = (Texture2D)EditorGUILayout.ObjectField(m_SelectTexture, typeof(Texture2D), true);
        EditorGUILayout.EndHorizontal();

        //EstimateElemType
        if (_tempTexture != m_SelectTexture)
        {
            m_SelectElemType = EstimateElemType(_tempTexture);
        }
        m_SelectTexture = _tempTexture;

        //Assign Elem Type
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Elem Type");
        m_SelectElemType = (TileMapElemType)EditorGUILayout.EnumPopup(m_SelectElemType);
        EditorGUILayout.EndHorizontal();
    }
Пример #4
0
 public static Color GetDebugColor(TileMapElemType vElemType)
 {
     return(S_ElemType2DebugColor [vElemType]);
 }
Пример #5
0
 public static bool IsObstacle(TileMapElemType vElemType)
 {
     return((int)vElemType > (int)TileMapElemType.Grass);
 }