Esempio n. 1
0
    private void ToggleActiveInternal()
    {
        if (!m_active)
        {
            int       l_tileSizeX = Singleton <TerrainManager> .instance.m_patches[0].m_surfaceMapA.width;
            int       l_tileSizeY = Singleton <TerrainManager> .instance.m_patches[0].m_surfaceMapA.height;
            Texture2D l_overlay   = GetOverlayTexture(l_tileSizeX * 9, l_tileSizeY * 9);

            if (l_overlay == null)
            {
                OverLayerExtension.DebugLog("Could not load image. Are you sure it is placed at the correct location?");
                return;
            }

            m_lastTexture = l_overlay;
            m_lastTexture.Apply();
            m_active = true;
            NotifyDelegate();
        }
        else
        {
            m_active = false;
            NotifyDelegate();
        }
    }
Esempio n. 2
0
    public static void OnLevelLoaded()
    {
        OverLayerExtension.DebugLog("Is registered: " + m_hasRegistered);

        if (!m_hasRegistered)
        {
            SimulationManager.RegisterManager(instance);
            m_hasRegistered = true;

            OverLayerExtension.DebugLog("Registered Manager");
        }
    }
Esempio n. 3
0
    private Texture2D GetOverlayTexture(int p_width, int p_height)
    {
        try
        {
            DateTime l_newBytesWrite = File.GetLastWriteTime(c_filename);

            if (m_lastBytesWrite != null && m_lastTexture != null && !Input.GetKey(KeyCode.LeftShift))
            {
                if (m_lastBytesWrite.Equals(l_newBytesWrite))
                {
                    OverLayerExtension.DebugLog("Using cached image. Activate while holding shift to force reload.");
                    return(m_lastTexture);
                }
            }

            OverLayerExtension.DebugLog("Loading image.");

            byte[] l_bytes = File.ReadAllBytes(c_filename);
            m_lastBytesWrite = l_newBytesWrite;

            Texture2D l_texture = new Texture2D(p_width, p_height);
            m_lastTexture = new Texture2D(p_width, p_height);

            l_texture.LoadImage(l_bytes);
            m_lastTexture.LoadImage(l_bytes);

            // We need to flip the image for some reason?
            for (int y = 0; y < l_texture.height; ++y)
            {
                for (int x = 0; x < l_texture.width; ++x)
                {
                    m_lastTexture.SetPixel(x, y, l_texture.GetPixel(y, x));
                }
            }

            return(m_lastTexture);
        }
        catch (Exception p_exception)
        {
            OverLayerExtension.DebugLog("Got exception: " + p_exception.Message);
            return(null);
        }
    }