Пример #1
0
 public static void SetResolution(this DecorationRenderer renderer, int resolution)
 {
     renderer.m_renderDiffuseTexture = new RenderTexture(resolution, resolution, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear)
     {
         filterMode = FilterMode.Trilinear
     };
     renderer.m_renderXycaTexture = new RenderTexture(resolution, resolution, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear)
     {
         filterMode = FilterMode.Trilinear
     };
 }
Пример #2
0
 internal void OnLevelLoaded()
 {
     InGame     = true;
     Dispatcher = gameObject.AddComponent <UnityMainThreadDispatcher>();
     Load(DecorationType.Cliff);
     Load(DecorationType.Fertile);
     Load(DecorationType.Grass);
     Terrain.m_useGrassDecorations   = Settings.UseGrassDecorations;
     Terrain.m_useFertileDecorations = Settings.UseFertileDecorations;
     Terrain.m_useCliffDecorations   = Settings.UseCliffDecorations;
     DecorationRenderer.SetResolution((int)Settings.SelectedResolution);
     UpdateDensity(Settings.Density);
 }
Пример #3
0
        internal IEnumerator LoadResources(CustomDecorationsData pack, DecorationType type)
        {
            var cliffNames   = new string[] { "cliff0", "cliff1", "cliff2", "cliff3" };
            var fertileNames = new string[] { "fertile0", "fertile1", "fertile2", "fertile3" };
            var grassNames   = new string[] { "grass0", "grass1", "grass2", "grass3" };

            var names            = type == DecorationType.Cliff ? cliffNames : type == DecorationType.Fertile ? fertileNames : type == DecorationType.Grass ? grassNames : null;
            var decorationTarget = type == DecorationType.Cliff ? CliffDecorations : type == DecorationType.Fertile ? FertileDecorations : type == DecorationType.Grass ? GrassDecorations : null;

            for (int i = 0; i < decorationTarget.Length; i++)
            {
                var texturePath = Path.Combine(pack.ResourcesPath, names[i] + ".png");

                var textureXYCAPath = Path.Combine(pack.ResourcesPath, names[i] + "XYCA.png");

                var meshPath = Path.Combine(pack.ResourcesPath, names[i] + ".obj");

                var texture = Util.LoadTexture(texturePath);

                yield return(null);

                var textureXYCA = Util.LoadTexture(textureXYCAPath);

                yield return(null);

                var mesh = Util.LoadMesh(meshPath);

                yield return(null);

                decorationTarget[i].m_mesh = mesh;

                decorationTarget[i].m_renderMaterial.SetTexture("_MainTex", texture);

                if (textureXYCA)
                {
                    decorationTarget[i].m_renderMaterial.SetTexture("_XYCAMap", textureXYCA);
                }
            }

            DecorationRenderer.SetResolution((int)Settings.SelectedResolution);

            yield break;
        }