public void SetAtlasImageSprite(AtlasImage img, string socialId, string imgUrl)
 {
     if (img == null)
     {
         return;
     }
     GetImageSprite2(socialId, imgUrl, delegate(Sprite sp)
     {
         img.sprite = sp;
     });
 }
    void TextReset(Text textObj, string str, float delay)
    {
        textObj.text = str;

        AtlasImage image = textObj.transform.GetComponentInChildren <AtlasImage>();

        image.DOFade(0, 0).OnComplete(() =>
        {
            image.DOFade(1, 0.5f).SetDelay(delay);
        });
    }
Beispiel #3
0
        /// <summary>
        /// インスペクタGUIコールバック.
        /// Inspectorウィンドウを表示するときにコールされます.
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
//			using (new EditorGUI.DisabledGroupScope(true))
//			{
//				EditorGUILayout.PropertyField(m_Script);
//			}

            //アトラスとスプライトを表示.
//			EditorGUILayout.PropertyField(spAtlas);


            DrawAtlasPopupLayout(new GUIContent("Sprite Atlas"), new GUIContent("-"), spAtlas);
            EditorGUI.indentLevel++;
            DrawSpritePopup(spAtlas.objectReferenceValue as SpriteAtlas, spSpriteName);
            EditorGUI.indentLevel--;
//			serializedObject.ApplyModifiedProperties();

//			base.OnInspectorGUI ();

            //Imageインスペクタの再現. ▼ ここから ▼.
            AppearanceControlsGUI();
            RaycastControlsGUI();

            animShowType.target = spAtlas.objectReferenceValue && !string.IsNullOrEmpty(spSpriteName.stringValue);
            if (EditorGUILayout.BeginFadeGroup(animShowType.faded))
            {
                this.TypeGUI();
            }
            EditorGUILayout.EndFadeGroup();

            Image.Type imageType = (Image.Type)spType.intValue;
            base.SetShowNativeSize(imageType == Image.Type.Simple || imageType == Image.Type.Filled, false);

            if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(spPreserveAspect);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();
            base.NativeSizeButtonGUI();
            //Imageインスペクタの再現. ▲ ここまで ▲.


            serializedObject.ApplyModifiedProperties();

            //プレビューを更新.
            AtlasImage image = target as AtlasImage;

            preview.sprite = GetOriginalSprite(image.spriteAtlas, image.spriteName);
            preview.color  = image ? image.canvasRenderer.GetColor() : Color.white;
        }
Beispiel #4
0
    private void ExportTexture()
    {
        atlasDictionary.Clear();

        var xmlDoc  = new XmlDocument();
        var xmlFile = AssetDatabase.LoadAssetAtPath <TextAsset>(_atlasFile);

        xmlDoc.LoadXml(xmlFile.text);
        XmlNodeList atlasNodeList = xmlDoc.GetElementsByTagName("list");

        foreach (XmlNode listNodeInfo in atlasNodeList)
        {
            XmlNode atlasNameAttr  = listNodeInfo.Attributes.GetNamedItem("name");
            XmlNode atlasCountAttr = listNodeInfo.Attributes.GetNamedItem("count");

            if (atlasNameAttr == null)
            {
                Debug.LogWarning("atlas name is null, can't parse it");
                continue;
            }
            if (atlasCountAttr == null)
            {
                Debug.LogWarning("atlas count is null, can't parse it: " + atlasNameAttr.Value);
                continue;
            }
            string atlasFileName = _atlasFilePath + atlasNameAttr.Value + ".png";
            //Debug.Log("atlasFileName = " + atlasFileName);
            List <AtlasImage> atlasImageList = GetAtlasImageList(atlasFileName);
            int atlasCount = System.Convert.ToInt32(atlasCountAttr.Value);
            if (atlasCount == 1)
            {
                XmlNode atlasPathAttr = listNodeInfo.Attributes.GetNamedItem("path");
                if (atlasPathAttr == null)
                {
                    Debug.LogWarning("atlas count = 1, but path is null, can't parse it: " + atlasNameAttr.Value);
                }
                else
                {
                    AtlasImage img = new AtlasImage();
                    img.path = atlasPathAttr.Value;
                    img.x    = 0;
                    img.y    = 0;
                    img.w    = 0;
                    img.h    = 0;
                    atlasImageList.Add(img);
                    //Debug.Log("whole atlas picture copy to " + img.path + ", atlas name: " + atlasFileName);
                }
                continue;
            }
            XmlNode atlasSizeAttr = listNodeInfo.Attributes.GetNamedItem("size");
            if (atlasSizeAttr == null)
            {
                Debug.LogWarning("atlas size is null, can't parse it: " + atlasNameAttr.Value);
                continue;
            }
            string[] sizeSplits = atlasSizeAttr.Value.Split('|');
            if (sizeSplits.Length != 2)
            {
                Debug.LogWarning("atlas size format invalid: " + atlasSizeAttr.Value);
            }
            int atlasImageHeight = System.Convert.ToInt32(sizeSplits[1]);

            int         nodeCount   = 0;
            XmlNodeList imgNodeList = listNodeInfo.ChildNodes;
            foreach (XmlNode imageNodeInfo in imgNodeList)
            {
                XmlNode imgPathAttr = imageNodeInfo.Attributes.GetNamedItem("path");
                XmlNode imgXAttr    = imageNodeInfo.Attributes.GetNamedItem("x");
                XmlNode imgYAttr    = imageNodeInfo.Attributes.GetNamedItem("y");
                XmlNode imgWAttr    = imageNodeInfo.Attributes.GetNamedItem("w");
                XmlNode imgHAttr    = imageNodeInfo.Attributes.GetNamedItem("h");
                if (imgPathAttr == null || imgXAttr == null || imgYAttr == null || imgWAttr == null || imgHAttr == null)
                {
                    Debug.LogWarning("invalid image node: " + imgPathAttr.Value);
                    continue;
                }
                //Debug.Log("image path: " + imgPathAttr.Value);
                AtlasImage img = new AtlasImage();
                img.path = imgPathAttr.Value;
                img.x    = System.Convert.ToInt32(imgXAttr.Value);
                img.w    = System.Convert.ToInt32(imgWAttr.Value);
                img.h    = System.Convert.ToInt32(imgHAttr.Value);
                img.y    = atlasImageHeight - System.Convert.ToInt32(imgYAttr.Value) - img.h;
                atlasImageList.Add(img);
                nodeCount++;
            }

            if (nodeCount != atlasCount)
            {
                Debug.LogWarning("xml node count " + nodeCount + " don't equal to atlas count " + atlasCount);
            }
        }

        GenerateTextures();
    }
    private void ExportTexture()
    {
        atlasDictionary.Clear();

        var xmlDoc = new XmlDocument();
        var xmlFile = AssetDatabase.LoadAssetAtPath<TextAsset>(_atlasFile);
           		xmlDoc.LoadXml(xmlFile.text);
           		XmlNodeList atlasNodeList = xmlDoc.GetElementsByTagName("list");
           		foreach (XmlNode listNodeInfo in atlasNodeList) {
           			XmlNode atlasNameAttr = listNodeInfo.Attributes.GetNamedItem("name");
           			XmlNode atlasCountAttr = listNodeInfo.Attributes.GetNamedItem("count");

           			if (atlasNameAttr == null) {
           				Debug.LogWarning("atlas name is null, can't parse it");
           				continue;
           			}
           			if (atlasCountAttr == null) {
           				Debug.LogWarning("atlas count is null, can't parse it: " + atlasNameAttr.Value);
           				continue;
           			}
           			string atlasFileName = _atlasFilePath + atlasNameAttr.Value + ".png";
           			//Debug.Log("atlasFileName = " + atlasFileName);
           			List<AtlasImage> atlasImageList = GetAtlasImageList(atlasFileName);
           			int atlasCount = System.Convert.ToInt32(atlasCountAttr.Value);
           			if (atlasCount == 1) {
           				XmlNode atlasPathAttr = listNodeInfo.Attributes.GetNamedItem("path");
           				if (atlasPathAttr == null) {
           					Debug.LogWarning("atlas count = 1, but path is null, can't parse it: " + atlasNameAttr.Value);
           				} else {
           					AtlasImage img = new AtlasImage();
           					img.path = atlasPathAttr.Value;
           					img.x = 0;
           					img.y = 0;
           					img.w = 0;
           					img.h = 0;
           					atlasImageList.Add(img);
           					//Debug.Log("whole atlas picture copy to " + img.path + ", atlas name: " + atlasFileName);
           				}
           				continue;
           			}
           			XmlNode atlasSizeAttr = listNodeInfo.Attributes.GetNamedItem("size");
           			if (atlasSizeAttr == null) {
           				Debug.LogWarning("atlas size is null, can't parse it: " + atlasNameAttr.Value);
           				continue;
           			}
           			string[] sizeSplits = atlasSizeAttr.Value.Split('|');
           			if (sizeSplits.Length != 2) {
           				Debug.LogWarning("atlas size format invalid: " + atlasSizeAttr.Value);
           			}
           			int atlasImageHeight = System.Convert.ToInt32(sizeSplits[1]);

           			int nodeCount = 0;
           			XmlNodeList imgNodeList = listNodeInfo.ChildNodes;
           			foreach (XmlNode imageNodeInfo in imgNodeList) {
           				XmlNode imgPathAttr = imageNodeInfo.Attributes.GetNamedItem("path");
           				XmlNode imgXAttr = imageNodeInfo.Attributes.GetNamedItem("x");
           				XmlNode imgYAttr = imageNodeInfo.Attributes.GetNamedItem("y");
           				XmlNode imgWAttr = imageNodeInfo.Attributes.GetNamedItem("w");
           				XmlNode imgHAttr = imageNodeInfo.Attributes.GetNamedItem("h");
           				if (imgPathAttr == null || imgXAttr == null || imgYAttr == null || imgWAttr == null || imgHAttr == null) {
           					Debug.LogWarning("invalid image node: " + imgPathAttr.Value);
           					continue;
           				}
           				//Debug.Log("image path: " + imgPathAttr.Value);
           				AtlasImage img = new AtlasImage();
                img.path = imgPathAttr.Value;
                img.x = System.Convert.ToInt32(imgXAttr.Value);
                img.w = System.Convert.ToInt32(imgWAttr.Value);
                img.h = System.Convert.ToInt32(imgHAttr.Value);
                img.y = atlasImageHeight - System.Convert.ToInt32(imgYAttr.Value) - img.h;
                atlasImageList.Add(img);
           				nodeCount++;
           			}

           			if (nodeCount != atlasCount) {
           				Debug.LogWarning("xml node count " + nodeCount + " don't equal to atlas count " + atlasCount);
           			}
           		}

           		GenerateTextures();
    }