Ejemplo n.º 1
0
    protected override void DrawIconSpriteUI(NJGMapBase.MapItemType mapItem)
    {
        if (m.atlas != null)
        {
            string spr = mapItem.sprite;

            IconField("Icon Sprite", spr, delegate(string sp)
            {
                mapItem.sprite = sp;
                Save(true);
            }, GUILayout.Width(120f));

            float extraSpace = 0;

            // Draw sprite preview.
            if (mMat == null)
            {
                mMat = m.atlas.spriteMaterial;
            }

            if (mMat != null)
            {
                Texture2D tex = mMat.mainTexture as Texture2D;

                if (tex != null)
                {
                    NJGAtlas.Sprite sprite = m.atlas.GetSprite(spr);

                    if (sprite != null)
                    {
                        int size = mapItem.useCustomSize ? mapItem.size : m.iconSize;
                        GUILayout.Space(4f);
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space((Screen.width - 100) - size);
                            GUI.color = mMat.color = mapItem.color;

                            DrawSprite(tex, sprite.uvs, null, false, size, new Vector2(0, 18));
                            GUI.color = Color.white;
                        }
                        GUILayout.EndHorizontal();

                        extraSpace = size * (float)sprite.height / sprite.width;
                    }
                }
                extraSpace = Mathf.Max(0f, extraSpace - 24f);
                GUILayout.Space(extraSpace);
            }
        }
    }
Ejemplo n.º 2
0
    /*protected override void ChangeLayer(int layer)
     * {
     *  if (m.uiCam == null) m.uiCam = m.GetComponentInChildren<UICamera>();
     *  if (m.uiCam != null) if (m.uiCam.eventReceiverMask != 1 << m.gameObject.layer) m.uiCam.eventReceiverMask = 1 << m.gameObject.layer;
     *
     * }*/

    protected override void DrawIconSpriteUI(NJGMapBase.MapItemType mapItem)
    {
        if (m.atlas != null)
        {
            if (string.IsNullOrEmpty(mSpriteName))
            {
                mSpriteName = m.atlas.spriteList[0].name;
            }
            string spr = string.IsNullOrEmpty(mapItem.sprite) ? mSpriteName : mapItem.sprite;

            SpriteField("Icon Sprite", m.atlas, spr, delegate(string sp)
            {
                mapItem.OnSelectSprite(sp);
                Save(true);
            });

            EditorGUILayout.Separator();

            //if (string.IsNullOrEmpty(mSelSpriteName)) mSelSpriteName = m.atlas.spriteList[0].name;
            string spr2 = mapItem.selectedSprite;

            SpriteField("Selection Sprite", m.atlas, spr2, delegate(string sp)
            {
                mapItem.OnSelectBorderSprite(sp);
                Save(true);
            });

            float extraSpace = 0;

            // Draw sprite preview.
            Material mat = m.atlas.spriteMaterial;

            if (mat != null)
            {
                Texture2D tex = mat.mainTexture as Texture2D;

                if (tex != null)
                {
                    UISpriteData mSprite  = m.atlas.GetSprite(spr);
                    UISpriteData mSSprite = m.atlas.GetSprite(spr2);

                    if (mSprite != null)
                    {
                        Rect rect = new Rect(mSprite.x, mSprite.y, mSprite.width, mSprite.height);
                        rect = NGUIMath.ConvertToTexCoords(rect, tex.width, tex.height);

                        int  size  = mapItem.useCustomSize ? mapItem.size : m.iconSize;
                        Rect rect2 = new Rect();

                        if (mSSprite != null)
                        {
                            rect2 = new Rect(mSSprite.x, mSSprite.y, mSSprite.width, mSSprite.height);
                            rect2 = NGUIMath.ConvertToTexCoords(rect2, tex.width, tex.height);
                        }

                        int size2 = mapItem.useCustomBorderSize ? mapItem.borderSize : m.borderSize;

                        int s = Mathf.Max(size, size2);

                        GUILayout.Space(4f);
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space((Screen.width - 220) - size);
                            GUI.color = mapItem.color;
                            DrawSprite(tex, rect, null, false, size, new Vector2(0, 18));

                            if (mSSprite != null && rect2.width != 0)
                            {
                                //int sps = size / 4;
                                //Debug.Log("Border "+rect2+" / "+size2+" / "+sps);
                                DrawSprite(tex, rect2, null, false, size2, new Vector2(0, 18));                                 //new Vector2(sps, 18 + sps)
                            }
                            GUI.color = Color.white;
                        }
                        GUILayout.EndHorizontal();

                        extraSpace = s * (float)mSprite.height / mSprite.width;
                    }
                }

                extraSpace = Mathf.Max(0f, extraSpace - 10f);
                GUILayout.Space(extraSpace);
            }
        }
    }
Ejemplo n.º 3
0
    protected override void DrawArrowSpriteUI(NJGMapBase.MapItemType mapItem)
    {
        if (m.atlas != null && mapItem.haveArrow)
        {
            GUILayout.BeginVertical("Box");

            if (string.IsNullOrEmpty(mSpriteName))
            {
                mSpriteName = m.atlas.spriteList[0].name;
            }
            string spr = string.IsNullOrEmpty(mapItem.arrowSprite) ? mSpriteName : mapItem.arrowSprite;

            mapItem.arrowOffset = EditorGUILayout.IntField("Arrow Offset", mapItem.arrowOffset);
            mapItem.arrowRotate = EditorGUILayout.Toggle("Arrow Rotate", mapItem.arrowRotate);

            SpriteField("Arrow Sprite", m.atlas, spr, delegate(string sp)
            {
                mapItem.OnSelectArrowSprite(sp);
                Save(true);
            });

            float extraSpace = 0;

            // Draw sprite preview.
            Material mat = m.atlas.spriteMaterial;

            if (mat != null)
            {
                Texture2D tex = mat.mainTexture as Texture2D;

                if (tex != null)
                {
                    UISpriteData mSprite = m.atlas.GetSprite(spr);

                    if (mSprite != null)
                    {
                        Rect rect = new Rect(mSprite.x, mSprite.y, mSprite.width, mSprite.height);
                        rect = NGUIMath.ConvertToTexCoords(rect, tex.width, tex.height);

                        GUILayout.Space(4f);
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space((Screen.width - 220) - m.arrowSize);
                            GUI.color = mapItem.color;
                            DrawSprite(tex, rect, null, false, m.arrowSize, new Vector2(0, 18));
                            GUI.color = Color.white;
                        }
                        GUILayout.EndHorizontal();

                        extraSpace = m.arrowSize * (float)mSprite.height / mSprite.width;
                    }
                }

                extraSpace = Mathf.Max(0f, extraSpace - 10f);
                GUILayout.Space(extraSpace);
            }
            // Depth

            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Arrow Depth");

                int depth = mapItem.arrowDepth;
                if (GUILayout.Button("Back", GUILayout.Width(60f)))
                {
                    --depth;
                }
                depth = EditorGUILayout.IntField(depth);
                if (GUILayout.Button("Forward", GUILayout.Width(60f)))
                {
                    ++depth;
                }

                if (mapItem.arrowDepth != depth)
                {
                    mapItem.arrowDepth = depth;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
    }
Ejemplo n.º 4
0
    protected override void DrawArrowSpriteUI(NJGMapBase.MapItemType mapItem)
    {
        if (m.atlas != null && mapItem.haveArrow)
        {
            GUILayout.BeginVertical("Box");

            //if (string.IsNullOrEmpty(mSpriteName)) mSpriteName = m.atlas.spriteList[0].name;
            //string spr = string.IsNullOrEmpty(mapItem.arrowSprite) ? mSpriteName : mapItem.arrowSprite;
            string spr = mapItem.arrowSprite;

            mapItem.arrowOffset = EditorGUILayout.IntField("Arrow Offset", mapItem.arrowOffset);
            mapItem.arrowRotate = EditorGUILayout.Toggle("Arrow Rotate", mapItem.arrowRotate);

            IconField("Arrow Sprite", spr, delegate(string sp)
            {
                mapItem.arrowSprite = sp;
                Save(true);
            }, GUILayout.Width(120f));

            float extraSpace = 0;

            // Draw sprite preview.
            if (mMat == null)
            {
                mMat = m.atlas.spriteMaterial;
            }

            if (mMat != null)
            {
                Texture2D tex = mMat.mainTexture as Texture2D;

                if (tex != null)
                {
                    NJGAtlas.Sprite sprite = m.atlas.GetSprite(spr);

                    if (sprite != null)
                    {
                        GUILayout.Space(4f);
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space((Screen.width - 100) - m.arrowSize);
                            GUI.color = mMat.color = mapItem.color;
                            DrawSprite(tex, sprite.uvs, null, false, m.arrowSize, new Vector2(0, 18));
                            GUI.color = Color.white;
                        }
                        GUILayout.EndHorizontal();

                        extraSpace = m.arrowSize * (float)tex.height / tex.width;
                    }
                }
                extraSpace = Mathf.Max(0f, extraSpace - 20f);
                GUILayout.Space(extraSpace);
            }

            // Depth
            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Arrow Depth");

                int depth = mapItem.arrowDepth;
                if (GUILayout.Button("Back", GUILayout.Width(60f)))
                {
                    --depth;
                }
                depth = EditorGUILayout.IntField(depth);
                if (GUILayout.Button("Forward", GUILayout.Width(60f)))
                {
                    ++depth;
                }

                if (mapItem.arrowDepth != depth)
                {
                    mapItem.arrowDepth = depth;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
    }