Exemple #1
0
        /// <summary>
        /// Update layer mask for UICamera and Camera inside
        /// </summary>

        protected virtual void Update()
        {
            if (!Application.isPlaying)
            {
                //if (mCam == null) mCam = GetComponentInChildren<Camera>();
                //if (mCam != null) if (mCam.cullingMask != 1 << gameObject.layer) mCam.cullingMask = 1 << gameObject.layer;

                if (mapTexture != null)
                {
                    NJGTools.DestroyImmediate(mapTexture);
                }
            }
        }
    void Delete()
    {
        NJGTools.DestroyImmediate(m.gameObject);

        if (NJGMapZone.list.Count > 0)
        {
            Selection.activeGameObject = NJGMapZone.list[NJGMapZone.list.Count - 1].gameObject;
        }
        else
        {
            Selection.activeGameObject = NJGMapBase.instance.gameObject;
        }
    }
Exemple #3
0
    void Start()
    {
        if (map.boundLayers.value == 0)
        {
            Debug.LogWarning("Can't render map photo. You have not choosen any layer for bounds calculation. Go to the NJGMiniMap inspector.", map);
            NJGTools.DestroyImmediate(gameObject);
            return;
        }

        if (map.renderLayers.value == 0)
        {
            Debug.LogWarning("Can't render map photo. You have not choosen any layer for rendering. Go to the NJGMiniMap inspector.", map);
            NJGTools.DestroyImmediate(gameObject);
            return;
        }

        ConfigCamera();

        //if (map.optimize) StartCoroutine(DelayedDestroy(gameObject, 2));
        if (!Application.isPlaying)
        {
            Render();
        }
    }
Exemple #4
0
        /// <summary>
        /// Redraw the map's texture.
        /// </summary>

        public void Render()
        {
            if (map == null)
            {
                map = NJGMap.instance;
            }

            if (Time.time >= lastRender)
            {
#if UNITY_EDITOR
                if (Application.isPlaying)
                {
                    cam.targetTexture = null;
                    lastRender        = Time.time + 1f;
                }
#endif
                mReaded    = false;
                mApplied   = false;
                mGenerated = false;
                mWarning   = false;

                if (!map.optimize)
                {
                    canRender = true;
                }

                if (map.mapSize.x == 0 || map.mapSize.y == 0)
                {
                    map.mapSize = new Vector2(Screen.width, Screen.height);
                }

                if (map.generateMapTexture)
                {
                    if (map.userMapTexture != null)
                    {
                        NJGTools.Destroy(map.userMapTexture);
                        map.userMapTexture = null;
                    }

                    /*if (map.mapTexture != null)
                     * {
                     *  NJGTools.DestroyImmediate(map.mapTexture);
                     *  map.mapTexture = null;
                     * }*/

                    if (map.mapTexture == null)
                    {
                        mSize = map.mapSize;
                        if (map.mapResolution == NJGMap.Resolution.Double)
                        {
                            mSize = map.mapSize * 2;
                        }
                        map.mapTexture            = new Texture2D((int)mSize.x, (int)mSize.y, (TextureFormat)map.textureFormat, map.generateMipmaps);
                        map.mapTexture.name       = "_NJGMapTexture";
                        map.mapTexture.filterMode = map.mapFilterMode;
                        map.mapTexture.wrapMode   = map.mapWrapMode;
                        lastSize = mSize;
                    }
                }
                else if (!Application.isPlaying)
                {
                    if (map.mapTexture != null)
                    {
                        NJGTools.DestroyImmediate(map.mapTexture);
                        map.mapTexture = null;
                    }

                    //if (map.userMapTexture != null)
                    //{
                    map.userMapTexture            = new Texture2D((int)map.mapSize.x, (int)map.mapSize.y, (TextureFormat)map.textureFormat, map.generateMipmaps);
                    map.userMapTexture.name       = "_NJGTempTexture";
                    map.userMapTexture.filterMode = map.mapFilterMode;
                    map.userMapTexture.wrapMode   = map.mapWrapMode;
                    //}
                }


                ConfigCamera();
                cam.enabled = true;
                if (!Application.isPlaying)
                {
                    cam.Render();
                }
            }
        }