Beispiel #1
0
        public void SetPreviewGrassTexture()
        {
            TC_Settings localSettings = TC_Settings.instance;

            if (localSettings.hasMasterTerrain)
            {
                if (selectIndex < localSettings.masterTerrain.terrainData.detailPrototypes.Length && selectIndex >= 0)
                {
                    DetailPrototype detailPrototype = localSettings.masterTerrain.terrainData.detailPrototypes[selectIndex];
                    if (detailPrototype.usePrototypeMesh)
                    {
                        #if UNITY_EDITOR
                        preview.tex = UnityEditor.AssetPreview.GetAssetPreview(detailPrototype.prototype);
                        #endif
                    }
                    else
                    {
                        preview.tex = detailPrototype.prototypeTexture;
                    }
                    if (preview.tex != null)
                    {
                        name = Mathw.CutString(preview.tex.name, TC.nodeLabelLength);
                    }
                }
                else
                {
                    active = false;
                }
            }
            else
            {
                preview.tex = null;
            }
        }
Beispiel #2
0
        public void SetPreviewTreeTexture()
        {
            #if UNITY_EDITOR
            TC_Settings settings = TC_Settings.instance;

            if (settings.hasMasterTerrain)
            {
                TreePrototype[] treePrototypes = settings.masterTerrain.terrainData.treePrototypes;
                if (selectIndex < treePrototypes.Length && selectIndex >= 0)
                {
                    if (treePrototypes[selectIndex].prefab)
                    {
                        preview.tex = UnityEditor.AssetPreview.GetAssetPreview(treePrototypes[selectIndex].prefab);
                        name        = Mathw.CutString(treePrototypes[selectIndex].prefab.name, TC.nodeLabelLength);
                    }
                }
                else
                {
                    active = false;
                }
            }
            else
            {
                preview.tex = null;
            }
            #endif
        }
Beispiel #3
0
        public void SetPreviewSplatTexture()
        {
            TC_Settings localSettings = TC_Settings.instance;

            if (localSettings.hasMasterTerrain)
            {
                Texture2D splatTexture;
                int       length = TC.GetTerrainSplatTexture(localSettings.masterTerrain, selectIndex, out splatTexture);

                if (selectIndex < length && selectIndex >= 0)
                {
                    preview.tex = splatTexture;
                    if (preview.tex != null)
                    {
                        name = Mathw.CutString(preview.tex.name, TC.nodeLabelLength);
                    }
                }
                else
                {
                    active = false;
                }
            }
            else
            {
                preview.tex = null;
            }
        }
Beispiel #4
0
        public void SetPreviewObjectTexture()
        {
            #if UNITY_EDITOR
            if (spawnObject == null)
            {
                preview.tex = null; return;
            }
            if (spawnObject.go == null)
            {
                // Debug.Log("preview tex is set to null");
                preview.tex = null;
                return;
            }
            // Debug.Log("Yes");
            preview.tex = UnityEditor.AssetPreview.GetAssetPreview(spawnObject.go);
            name        = Mathw.CutString(spawnObject.go.name, TC.nodeLabelLength);
            #endif

            // Debug.Log("SetPreviewObjectTexture");
        }
Beispiel #5
0
        public void SetPreviewSplatTexture()
        {
            TC_Settings localSettings = TC_Settings.instance;

            if (localSettings.hasMasterTerrain)
            {
                if (selectIndex < localSettings.masterTerrain.terrainData.splatPrototypes.Length && selectIndex >= 0)
                {
                    preview.tex = localSettings.masterTerrain.terrainData.splatPrototypes[selectIndex].texture;
                    if (preview.tex != null)
                    {
                        name = Mathw.CutString(preview.tex.name, TC.nodeLabelLength);
                    }
                }
                else
                {
                    active = false;
                }
            }
            else
            {
                preview.tex = null;
            }
        }