Beispiel #1
0
 public void GetLayerLevel()
 {
     // GameObject go = GameObject.Find("LayerLevel");
     // if (go != null) layerLevel = go.GetComponent<TCLayerLevel>(); else Debug.Log("Cant find layerLevelGroup");
     terrainLayer = TC_Area2D.current.terrainLayer;
     // layerLevel = Area2D.current.layerLevel;
 }
Beispiel #2
0
        void Open()
        {
            TC_Settings settings = TC_Settings.instance;

            string folder = settings.lastPath;

            if (!folder.Contains(Application.dataPath))
            {
                folder = "";
            }
            if (folder == "")
            {
                folder = Application.dataPath + TC.installPath.Replace("Assets", "") + "/Examples/Presets/TerrainLayer";
            }

            string path = EditorUtility.OpenFilePanel("Open TerrainComposer2 project", folder, "prefab");

            if (path.Length != 0)
            {
                settings.lastPath = TC.GetPath(path);

                string filePath = TC.GetAssetDatabasePath(path);

                if (TC.FileExists(filePath))
                {
                    GameObject go = Instantiate(AssetDatabase.LoadAssetAtPath(filePath, typeof(GameObject))) as GameObject;
                    if (go != null)
                    {
                        go.transform.hideFlags = HideFlags.HideInInspector;
                        TC_TerrainLayer terrainLayer = go.GetComponent <TC_TerrainLayer>();
                        if (terrainLayer != null)
                        {
                            go.transform.parent = TC_Generate.instance.transform.parent;
                            DestroyImmediate(TC_Area2D.current.terrainLayer.gameObject);
                            TC_Area2D.current.terrainLayer = terrainLayer;
                            DebugMode();
                            TC.AddMessage(TC.GetFileName(path) + " is loaded succesfully.");
                        }
                        else
                        {
                            TC.AddMessage("This is not a TerrainLayer prefab.");
                            DestroyImmediate(go);
                        }
                    }
                }
                else
                {
                    TC.AddMessage("Can't find path.");
                }
            }
        }
        static public void Draw(TC_TerrainLayer terrainLayer)
        {
            Vector2 pos = new Vector2(TC_NodeWindow.window.position.width / 2, TC_NodeWindow.window.position.height / 2);

            TD.DrawTextureScaled(pos.x, pos.y, TD.texShelfStart, Color.white, false, StretchMode.None, StretchMode.Screen);
            TD.DrawTextureScaled(pos.x + TD.texShelfStart.width, pos.y, TD.texShelfBackGround2, Color.white, false, StretchMode.Right, StretchMode.Screen);

            float scrollY = 0;

            for (int i = 0; i < 6; i++)
            {
                DrawLayerGroup(terrainLayer, i, ref pos, ref scrollY);
            }
        }
Beispiel #4
0
        public void LinkClone(TC_TerrainLayer terrainLayerS)
        {
            TC_LayerGroup layerGroup;

            for (int i = 0; i < layerGroups.Length; i++)
            {
                layerGroup = layerGroups[i];

                if (layerGroup != null)
                {
                    layerGroup.LinkClone(terrainLayerS.layerGroups[i]);
                }
            }
        }
        static public void DrawLayerGroup(TC_TerrainLayer terrainLayer, int index, ref Vector2 pos, ref float scrollY)
        {
            TC_GlobalSettings g            = TC_Settings.instance.global;
            Event             eventCurrent = Event.current;

            TC_LayerGroup layerGroup = terrainLayer.layerGroups[index];

            if (layerGroup == null)
            {
                return;
            }

            Vector2 posOld = pos;

            float t = 0;

            TC_LayerGroupGUI.Draw(layerGroup, false, ref pos, 1, false, false, ref t);

            Rect rect;

            rect = new Rect(posOld.x + 50, posOld.y - 18, 400, 100);
            TD.DrawTextureScaled(posOld.x - 44, posOld.y, 100, TD.texLineHorizontal, g.colLayerGroup);

            Color buttonColor;

            if (layerGroup.visible)
            {
                if (layerGroup.active)
                {
                    buttonColor = Color.green;
                }
                else
                {
                    buttonColor = Color.red;
                }
            }
            else
            {
                buttonColor = Color.white;
            }

            if (TD.DrawButton(rect, TC.outputNames[layerGroup.outputId], 64, true, Color.white, TD.editorSkinMulti == 1 ? buttonColor : new Color(buttonColor.r * 0.4f, buttonColor.g * 0.4f, buttonColor.b * 0.4f, 1)))
            {
                // Debug.Log("Clicked Button");
                TD.ClickOutputButton(layerGroup);
                eventCurrent.Use();
            }

            for (int i = 0; i < 3; i++)
            {
                rect = TD.GetRectScaled(pos.x - 32 + 25, pos.y + 33 + (i * 32), 32, 32); rect.xMin = 0;
                TD.DrawTexture(rect, TD.texSeparatorCenter, new Color(1, 1, 1, 0.5f));
                rect = TD.GetRectScaled(pos.x + 25, pos.y + 33 + (i * 32), 32, 32);
                TD.DrawTexture(rect, TD.texSeparatorRight, new Color(1, 1, 1, 0.5f));
            }

            pos.y += TD.cardHeight;
            pos.y += g.outputVSpace;

            // scrollY += startY - startOffset.y;
            // else GlobalManager.singleton.scrollAdd.y = 0;
            pos.x = posOld.x;
        }
 public TerrainLayerGroupItem(TC_TerrainLayerGroup terrainLayerGroup, TC_TerrainLayer terrainLayer)
 {
     this.terrainLayer      = terrainLayer;
     this.terrainLayerGroup = terrainLayerGroup;
 }
Beispiel #7
0
        static int LoadDefault()
        {
            if (!NewScene())
            {
                return(-1);
            }

            GameObject defaultGo = AssetDatabase.LoadAssetAtPath(TC.installPath + "/Defaults/TerrainComposer2.prefab", typeof(GameObject)) as GameObject;

            if (defaultGo != null)
            {
                GameObject go = Instantiate(defaultGo, Vector3.zero, Quaternion.identity) as GameObject;

                if (go == null)
                {
                    return(-2);
                }
                else
                {
                    go.transform.hideFlags = HideFlags.HideInInspector;
                    go.name = go.name.Replace("(Clone)", "");
                    go.transform.SetAsFirstSibling();
                    DebugMode();

                    if (!TC.LoadGlobalSettings())
                    {
                        return(-2);
                    }

                    Transform generateT = go.transform.Find("Generate");
                    if (generateT != null)
                    {
                        TC_Compute compute = generateT.GetComponent <TC_Compute>();

                        if (compute != null)
                        {
                            compute.enabled = true;
                        }
                        else
                        {
                            return(-2);
                        }
                    }
                    else
                    {
                        return(-2);
                    }
                }
            }
            else
            {
                return(-2);
            }

            if (GameObject.Find("Terrain Area") == null)
            {
                GameObject terrainAreaGo = AssetDatabase.LoadAssetAtPath(TC.installPath + "/Defaults/Terrain Area.prefab", typeof(GameObject)) as GameObject;
                if (terrainAreaGo != null)
                {
                    GameObject go = Instantiate(terrainAreaGo, Vector3.zero, Quaternion.identity) as GameObject;

                    TC_TerrainLayer terrainLayer = TC_Generate.instance.area2D.terrainLayer;

                    terrainLayer.GetItems(false, true, false);

                    // Detect prefab import issue
                    if (terrainLayer.layerGroups[TC.splatOutput].visible)
                    {
                        TC.AddMessage("TerrainComposer2 prefabs did not import correctly.\n\nYou need to be reimport TerrainComposer2 again (So import it twice).\n\nThis happens if ‘Asset Serialization’ is set to ‘Force Text’ in Unity Menu -> Project Settings -> Editor. It is a Unity import bug that can happen on any Asset. If that does not fix it, the ‘Asset Serialization’ can be set to ‘Mixed’ and then reimport TC2 again, then after importing the ‘Asset Serialization’ can be set to ‘Force Text’ again.", 0, 60);
                    }
                    else if (go == null)
                    {
                        TC.AddMessage("Default Terrain Area prefab is missing. Please reimport this prefab.");
                    }
                    go.name = go.name.Replace("(Clone)", "");
                }
                else
                {
                    TC.AddMessage("Default Terrain Area prefab is missing. Please reimport this prefab.");
                }
            }

            TC.AddMessage("Loading default TerrainComposer project.");

            return(0);
        }