public static void ValidateTexture(ref TerrainParameters currentParameter)
 {
     // Edge case if textures exist in runtime
     if (currentParameter.TexturePath == null && currentParameter.TerrainTexture != null)
     {
         currentParameter.TexturePath = AssetDatabase.GetAssetPath(currentParameter.TerrainTexture);
     }
     if (currentParameter.TerrainTexture == null && currentParameter.TexturePath != null)
     {
         currentParameter.TerrainTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(currentParameter.TexturePath, typeof(Texture2D));
     }
 }
    private void ReorderableListDrawPresetObjecList(Rect rect, TerrainParameters tparam, int index)
    {
        rect.height = 22.0f;
        rect.y     += 22.0f;
        EditorGUI.LabelField(rect, "Terrain game objects");
        rect.height = 22.0f;
        rect.y     += 22.0f;
        var tmpWidth = rect.width;

        rect.width = tmpWidth / 2;
        if (GUI.Button(rect, "+"))
        {
            tparam.ObjectListCount++;
            tparam.TerrainParameterObjectList.Add(null);
            tparam.ObjectListPath.Add(string.Empty);
            tparam.TerrainParameterObjectCount.Add(0);
        }
        rect.x += rect.width;
        if (GUI.Button(rect, "-"))
        {
            if (tparam.ObjectListCount - 1 >= 0)
            {
                tparam.ObjectListCount--;
                tparam.TerrainParameterObjectList.RemoveAt(tparam.ObjectListCount);
                tparam.ObjectListPath.RemoveAt(tparam.ObjectListCount);
                tparam.TerrainParameterObjectCount.RemoveAt(tparam.ObjectListCount);
            }
        }
        rect.x                -= rect.width;
        rect.width             = tmpWidth / 2;
        rect.height            = 22.0f;
        rect.y                += 22.0f;
        ScrollPositions[index] = GUI.BeginScrollView(new Rect(rect.x, rect.y, Screen.width - 65, 125), ScrollPositions[index], new Rect(0, 0, 175, tparam.ObjectListCount * 26));
        var start_rect = new Rect(0, 0, 150, 16);

        for (int i = 0; i < tparam.ObjectListCount; i++)
        {
            var newTerrainObject = (GameObject)EditorGUI.ObjectField(start_rect, tparam.TerrainParameterObjectList[i], typeof(GameObject), false);
            start_rect.x += start_rect.width;
            tparam.TerrainParameterObjectCount[i] = EditorGUI.IntField(start_rect, tparam.TerrainParameterObjectCount[i]);
            if (newTerrainObject != tparam.TerrainParameterObjectList[i])
            {
                tparam.TerrainParameterObjectList[i] = newTerrainObject;
                tparam.ObjectListPath[i]             = AssetDatabase.GetAssetPath(newTerrainObject);
            }
            start_rect.x -= start_rect.width;
            start_rect.y += 22.0f;
        }
        GUI.EndScrollView();
    }
Example #3
0
    private void ReorderableListDrawPresetObjecList(Rect rect, TerrainParameters tparam)
    {
        rect.height = 22.0f;
        rect.y     += 22.0f;
        EditorGUI.LabelField(rect, "Terrain game objects");
        rect.height = 22.0f;
        rect.y     += 22.0f;
        var tmpWidth = rect.width;

        rect.width = tmpWidth / 2;
        if (GUI.Button(rect, "+"))
        {
            tparam.ObjectListCount++;
            tparam.TerrainParameterObjectList.Add(null);
            tparam.ObjectListPath.Add(string.Empty);
            tparam.TerrainParameterObjectCount.Add(0);
        }
        rect.x += rect.width;
        if (GUI.Button(rect, "-"))
        {
            if (tparam.ObjectListCount - 1 >= 0)
            {
                tparam.ObjectListCount--;
                tparam.TerrainParameterObjectList.RemoveAt(tparam.ObjectListCount);
                tparam.ObjectListPath.RemoveAt(tparam.ObjectListCount);
                tparam.TerrainParameterObjectCount.RemoveAt(tparam.ObjectListCount);
            }
        }
        rect.x     -= rect.width;
        rect.width  = tmpWidth / 2;
        rect.height = 22.0f;
        rect.y     += 22.0f;
        for (int i = 0; i < tparam.ObjectListCount; i++)
        {
            var newTerrainObject = (GameObject)EditorGUI.ObjectField(rect, tparam.TerrainParameterObjectList[i], typeof(GameObject), false);
            rect.x += rect.width;
            tparam.TerrainParameterObjectCount[i] = EditorGUI.IntField(rect, tparam.TerrainParameterObjectCount[i]);
            if (newTerrainObject != tparam.TerrainParameterObjectList[i])
            {
                tparam.TerrainParameterObjectList[i] = newTerrainObject;
                tparam.ObjectListPath[i]             = AssetDatabase.GetAssetPath(newTerrainObject);
            }
            rect.x     -= rect.width;
            rect.height = 22.0f;
            rect.y     += 22.0f;
        }
    }
 public static void ValidateTexture(ref TerrainParameters currentParameter)
 {
     // Edge case if textures exist in runtime
     if (currentParameter.TexturePathSpring == null && currentParameter.TerrainTextureSpring != null)
     {
         currentParameter.TexturePathSpring = AssetDatabase.GetAssetPath(currentParameter.TerrainTextureSpring);
     }
     if (currentParameter.TexturePathSummer == null && currentParameter.TerrainTextureSummer != null)
     {
         currentParameter.TexturePathSummer = AssetDatabase.GetAssetPath(currentParameter.TerrainTextureSummer);
     }
     if (currentParameter.TexturePathAutumn == null && currentParameter.TerrainTextureAutumn != null)
     {
         currentParameter.TexturePathAutumn = AssetDatabase.GetAssetPath(currentParameter.TerrainTextureAutumn);
     }
     if (currentParameter.TexturePathWinter == null && currentParameter.TerrainTextureWinter != null)
     {
         currentParameter.TexturePathWinter = AssetDatabase.GetAssetPath(currentParameter.TerrainTextureWinter);
     }
     // if we dont have the texture loaded but we have the path
     if (currentParameter.TerrainTextureSpring == null && currentParameter.TexturePathSpring != null)
     {
         currentParameter.TerrainTextureSpring = (Texture2D)AssetDatabase.LoadAssetAtPath(currentParameter.TexturePathSpring, typeof(Texture2D));
     }
     if (currentParameter.TerrainTextureSummer == null && currentParameter.TexturePathSummer != null)
     {
         currentParameter.TerrainTextureSummer = (Texture2D)AssetDatabase.LoadAssetAtPath(currentParameter.TexturePathSummer, typeof(Texture2D));
     }
     if (currentParameter.TerrainTextureAutumn == null && currentParameter.TexturePathAutumn != null)
     {
         currentParameter.TerrainTextureAutumn = (Texture2D)AssetDatabase.LoadAssetAtPath(currentParameter.TexturePathAutumn, typeof(Texture2D));
     }
     if (currentParameter.TerrainTextureWinter == null && currentParameter.TexturePathWinter != null)
     {
         currentParameter.TerrainTextureWinter = (Texture2D)AssetDatabase.LoadAssetAtPath(currentParameter.TexturePathWinter, typeof(Texture2D));
     }
 }