Exemple #1
0
    public static void checkRestrictions(GameObject pluginOption,
                                         TerrainPluginInfo terrainPluginInfo,
                                         List <TerrainPipelineLayer> configurationTerrainPipelineLayer,
                                         TerrainPipelineLayer currentPipelineLayer)
    {
        PluginOption pluginOptionScript = pluginOption.GetComponent <PluginOption>();

        if (currentPipelineLayer.LayerTypes.Count != terrainPluginInfo.Out.Count)
        {
            pluginOptionScript.InvalidateOut();
        }
        else
        {
            foreach (LayerType terrainPipelineLayerType in terrainPluginInfo.Out)
            {
                if (!currentPipelineLayer.LayerTypes.Contains(terrainPipelineLayerType))
                {
                    pluginOptionScript.InvalidateOut();
                    break;
                }
            }
        }

        List <LayerType> previousPipelineLayerTypes = new List <LayerType>();

        foreach (TerrainPipelineLayer terrainPipelineLayer in configurationTerrainPipelineLayer)
        {
            if (terrainPipelineLayer.LayerCode.Equals(currentPipelineLayer.LayerCode))
            {
                break;
            }

            previousPipelineLayerTypes.AddRange(terrainPipelineLayer.LayerTypes);
        }

        foreach (LayerType terrainPipelineLayerType in terrainPluginInfo.In)
        {
            if (!previousPipelineLayerTypes.Contains(terrainPipelineLayerType))
            {
                pluginOptionScript.InvalidateIn();
                break;
            }
        }

        foreach (LayerType terrainPipelineLayerType in terrainPluginInfo.Not)
        {
            if (previousPipelineLayerTypes.Contains(terrainPipelineLayerType))
            {
                pluginOptionScript.InvalidateNot();
                break;
            }
        }
    }
Exemple #2
0
    public static bool ArePluginRestrictionsMet(TerrainPluginInfo terrainPluginInfo, List <TerrainPipelineLayer> configurationTerrainPipelineLayer, TerrainPipelineLayer currentTerrainPipelineLayer)
    {
        UnityEngine.Object layerOptionPrefab = Resources.Load("Prefabs/PluginOption", typeof(GameObject));

        GameObject layerOption = ((GameObject)Instantiate(layerOptionPrefab));

        checkRestrictions(layerOption, terrainPluginInfo, configurationTerrainPipelineLayer, currentTerrainPipelineLayer);

        if (layerOption.GetComponent <PluginOption>().Valid)
        {
            return(true);
        }
        return(false);
    }
Exemple #3
0
    private GameObject createPluginOption(TerrainPluginInfo terrainPluginInfo)
    {
        UnityEngine.Object layerOptionPrefab = Resources.Load("Prefabs/PluginOption", typeof(GameObject));
        UnityEngine.Object terrainIconPrefab = Resources.Load("Prefabs/TerrainButtonIcon", typeof(GameObject));

        GameObject   layerOption  = ((GameObject)Instantiate(layerOptionPrefab));
        PluginOption pluginOption = layerOption.GetComponent <PluginOption>();

        pluginOption.Title.text       = terrainPluginInfo.Name;
        pluginOption.Author.text      = "Author: " + terrainPluginInfo.Author;
        pluginOption.Description.text = "Description: " + terrainPluginInfo.Description;

        foreach (LayerType terrainPipelineLayerType in TerrainProjectManager.InactiveTerrainLayerIcons.Keys)
        {
            // Out
            if (terrainPluginInfo.Out.Contains(terrainPipelineLayerType))
            {
                GameObject terrainIcon = (GameObject)Instantiate(terrainIconPrefab);
                terrainIcon.GetComponentInChildren <Image>().sprite = Resources.Load <Sprite>(TerrainProjectManager.InactiveTerrainLayerIcons[terrainPipelineLayerType]);
                terrainIcon.transform.SetParent(pluginOption.Out.transform);
            }

            // In
            if (terrainPluginInfo.In.Contains(terrainPipelineLayerType))
            {
                GameObject terrainIcon = (GameObject)Instantiate(terrainIconPrefab);
                terrainIcon.GetComponentInChildren <Image>().sprite = Resources.Load <Sprite>(TerrainProjectManager.InactiveTerrainLayerIcons[terrainPipelineLayerType]);
                terrainIcon.transform.SetParent(pluginOption.In.transform);
            }

            // Not
            if (terrainPluginInfo.Not.Contains(terrainPipelineLayerType))
            {
                GameObject terrainIcon = (GameObject)Instantiate(terrainIconPrefab);
                terrainIcon.GetComponentInChildren <Image>().sprite = Resources.Load <Sprite>(TerrainProjectManager.InactiveTerrainLayerIcons[terrainPipelineLayerType]);
                terrainIcon.transform.SetParent(pluginOption.Not.transform);
            }
        }

        checkRestrictions(layerOption, terrainPluginInfo, projectPanel.configurationTerrainPipelineLayer, this.terrainPipelineLayer);
        return(layerOption);
    }