public void WriteToJson(IResMgr resmgr, GameObject node, Component component, MyJson.JsonNode_Object json)
        {
            SkinnedMeshRenderer ic = component as SkinnedMeshRenderer;
            //json["type"] = new MyJson.JsonNode_ValueString(this.comptype.Name.ToLower());//必须的一行
            //放到外面去了

            //材质
            MyJson.JsonNode_Array mats = new MyJson.JsonNode_Array();

            json["mats"] = mats;

            foreach (var m in ic.sharedMaterials)
            {
                string hash = resmgr.SaveMat(m);
                mats.Add(new MyJson.JsonNode_ValueString(hash));
            }

            //bounds
            json["center"] = new MyJson.JsonNode_ValueString(StringHelper.ToString(ic.localBounds.center));
            json["size"] = new MyJson.JsonNode_ValueString(StringHelper.ToString(ic.localBounds.size));

            //mesh
            json["mesh"] = new MyJson.JsonNode_ValueString(resmgr.SaveMesh(ic.sharedMesh));

            json["rootboneobj"] = new MyJson.JsonNode_ValueNumber(ic.rootBone.gameObject.GetInstanceID());
            MyJson.JsonNode_Array bones = new MyJson.JsonNode_Array();
            foreach (var b in ic.bones)
            {
                bones.Add(new MyJson.JsonNode_ValueNumber(b.gameObject.GetInstanceID()));
            }
            json["boneobjs"] = bones;
            ic.rootBone.GetInstanceID();
        }
Esempio n. 2
0
    public MyJson.IJsonNode Parser(Component com, NeedList list)
    {
        MeshRenderer t = com as MeshRenderer;
        var json = new MyJson.JsonNode_Object();
        json["castShadows"] = new MyJson.JsonNode_ValueNumber(t.castShadows);
        json["receiveShadows"] = new MyJson.JsonNode_ValueNumber(t.receiveShadows);
        json["useLightProbes"] = new MyJson.JsonNode_ValueNumber(t.useLightProbes);
        int meshcount = t.sharedMaterials.Length;

        json["materials"] = new MyJson.JsonNode_Array();
        foreach (var m in t.sharedMaterials)
        {
            MyJson.JsonNode_Object matobj = new MyJson.JsonNode_Object();
            json["materials"].AddArrayValue(matobj);

            matobj.SetDictValue("name", m.name);
            matobj.SetDictValue("shader", m.shader.name);
            matobj.SetDictValue("shaderkeyword", new MyJson.JsonNode_Array());
            foreach (var shaderkey in m.shaderKeywords)
            {
                matobj["shaderkeyword"].AddArrayValue(shaderkey);
            }
            if (m.mainTexture != null)
            {
                string name = AssetMgr.SaveTexture(m.mainTexture, System.IO.Path.Combine(Application.streamingAssetsPath, "texture"));
                matobj.SetDictValue("maintex", name);
                list.AddDependTexture(name);
            }
        }
        return json;
    }
Esempio n. 3
0
    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {

        UISlider t = com as UISlider;
        var json = new MyJson.JsonNode_Object();

        json["value"] = new MyJson.JsonNode_ValueNumber(t.value);
        json["alpha"] = new MyJson.JsonNode_ValueNumber(t.alpha);
        json["numberOfSteps"] = new MyJson.JsonNode_ValueNumber(t.numberOfSteps);
        if (t.foregroundWidget != null)
        {
            json["foregroundWidget"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.foregroundWidget.gameObject));
        }
        if (t.backgroundWidget != null)
        {
            json["backgroundWidget"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.backgroundWidget.gameObject));
        }
        if (t.thumb != null)
        {
            json["thumb"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.thumb.gameObject));
        }
        json["fillDirection"] = new MyJson.JsonNode_ValueString(t.fillDirection.ToString());

        return json;

    }
Esempio n. 4
0
 public static void ParserWidget(MyJson.JsonNode_Object json, UIWidget widget)
 {
     json["w_color"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(widget.color));
     json["w_pivot"] = new MyJson.JsonNode_ValueString(widget.pivot.ToString());
     json["w_depth"] = new MyJson.JsonNode_ValueNumber(widget.depth);
     json["w_dimensions"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(new Vector2(widget.width, widget.height)));
     json["w_keepasp"] = new MyJson.JsonNode_ValueString(widget.keepAspectRatio.ToString());
     //json["w_asp"] = new MyJson.JsonNode_ValueNumber(widget.aspectRatio);
 }
Esempio n. 5
0
    public MyJson.IJsonNode Parser(Component com,NeedList list)
    {
        BoxCollider t = com as BoxCollider;
        var json = new MyJson.JsonNode_Object();

        json["isTrigger"] = new MyJson.JsonNode_ValueNumber(t.isTrigger);
        json["center"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector3ToString(t.center));
        json["size"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector3ToString(t.size));
        return json;
    }
Esempio n. 6
0
    public MyJson.IJsonNode Parser(Component com,NeedList needlist)
    {

        UISprite t = com as UISprite;
        var json = new MyJson.JsonNode_Object();

        //t.atlas atlas 有特殊的打包逻辑
        string atlas = AtlasMgr.SaveAtlas(t.atlas, System.IO.Path.Combine(Application.streamingAssetsPath, "nguiatlas"), System.IO.Path.Combine(Application.streamingAssetsPath, "nguitex"));
        json["atlas"] =new MyJson.JsonNode_ValueString( atlas);
        if(needlist!=null)
        {
            needlist.AddDependAtlas(atlas); 
        }

        json["spriteName"] = new MyJson.JsonNode_ValueString(t.spriteName);
        json["spriteType"] = new MyJson.JsonNode_ValueString(t.type.ToString());

        if (t.type == UISprite.Type.Simple)
        {
            json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString());
        }
        else if (t.type == UISprite.Type.Sliced)
        {
            json["centerType"] = new MyJson.JsonNode_ValueString(t.centerType.ToString());
            json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString());
        }
        else if (t.type == UISprite.Type.Tiled)
        {

        }
        else if (t.type == UISprite.Type.Filled)
        {
            json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString());
            json["fillDirection"] = new MyJson.JsonNode_ValueString(t.fillDirection.ToString());
            json["fillAmount"] = new MyJson.JsonNode_ValueNumber(t.fillAmount);
            json["invert"] = new MyJson.JsonNode_ValueNumber(t.invert);
        }
        else if(t.type== UISprite.Type.Advanced)
        {
            json["leftType"] = new MyJson.JsonNode_ValueString(t.leftType.ToString());
            json["rightType"] = new MyJson.JsonNode_ValueString(t.rightType.ToString());
            json["topType"] = new MyJson.JsonNode_ValueString(t.topType.ToString());
            json["bottomType"] = new MyJson.JsonNode_ValueString(t.bottomType.ToString());
            json["centerType"] = new MyJson.JsonNode_ValueString(t.centerType.ToString());
            json["flip"] = new MyJson.JsonNode_ValueString(t.flip.ToString());
        }

        ComponentParser.ParserWidget(json, t);

        return json;


    }
Esempio n. 7
0
    public MyJson.IJsonNode Parser(Component com,NeedList list)
    {
        UIAnchor t = com as UIAnchor;
        var json = new MyJson.JsonNode_Object();
        json["uiCamera"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ComponentToID(t.uiCamera));
        json["container"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.container));
        json["side"] = new MyJson.JsonNode_ValueString(t.side.ToString());
        json["runOnlyOnce"] = new MyJson.JsonNode_ValueNumber(t.runOnlyOnce);
        json["relativeOffset"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(t.relativeOffset));
        json["pixelOffset"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(t.pixelOffset));

        return json;
    }
Esempio n. 8
0
    public MyJson.IJsonNode Parser(Component com,NeedList list)
    {
        MeshCollider t = com as MeshCollider;
        var json = new MyJson.JsonNode_Object();

        json["isTrigger"] = new MyJson.JsonNode_ValueNumber(t.isTrigger);
        var name = AssetMgr.SaveMesh(t.sharedMesh, System.IO.Path.Combine(Application.streamingAssetsPath, "mesh"));
        list.AddDependMesh(name);
        json.SetDictValue("mesh", name);
        json.SetDictValue("convex", t.convex);
        json.SetDictValue("smoothSphereCollisions", t.smoothSphereCollisions);
        return json;
    }
    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {

        UIDragDropContainer t = com as UIDragDropContainer;
        var json = new MyJson.JsonNode_Object();

        if (t.reparentTarget != null)
        {
            json["reparentTarget"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.reparentTarget.gameObject));
        }
        
        return json;

    }
    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {

        UIDragScrollView t = com as UIDragScrollView;
        var json = new MyJson.JsonNode_Object();

        if (t.scrollView != null)
        {
            json["scrollView"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.scrollView.gameObject));
        }
        
        return json;

    }
Esempio n. 11
0
        public void WriteToJson(IResMgr resmgr, Material mat, MyJson.JsonNode_Object json)
        {
            json["shaderName"] = new MyJson.JsonNode_ValueString(this.shaderName);
            if (jsonConfig.ContainsKey("params"))
            {
                foreach (var item in jsonConfig["params"].asDict())
                {
                    //Debug.Log(item.Value);
                    string type = item.Value.asDict()["type"].AsString();
                    string flag = item.Value.asDict()["flags"].AsString();
                    string name = item.Value.asDict()["name"].AsString();
                    if (type == "Float" || type == "Range")
                    {
                        json[name] = new MyJson.JsonNode_ValueNumber(mat.GetFloat(name));
                    }
                    else if (type == "Vector")
                    {
                        json[name] = new MyJson.JsonNode_ValueString(StringHelper.ToString(mat.GetVector(name)));
                    }
                    else if (type == "Color")
                    {
                        json[name] = new MyJson.JsonNode_ValueString(StringHelper.ToString((Color32)mat.GetColor(name)));
                    }
                    else if (type == "Texture")
                    {
                        string texdim = item.Value.asDict()["texdim"].AsString();
                        var tex = mat.GetTexture(name);
                        if (tex != null)
                        {
                            if (texdim == "Tex2D")
                            {
                                string texname = resmgr.SaveTexture(tex as Texture2D);
                                json[name] = new MyJson.JsonNode_ValueString(texname);
                            }
                            else
                            {
                                throw new Exception("not support texdim:" + texdim);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("not support type:" + type);
                    }

                }
            }

        }
Esempio n. 12
0
    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {

        UIScrollView sv = com as UIScrollView;
        var json = new MyJson.JsonNode_Object();

        json["movement"] = new MyJson.JsonNode_ValueString(sv.movement.ToString());
        json["dragEffect"] = new MyJson.JsonNode_ValueString(sv.dragEffect.ToString());
        json["scrollWheelFactor"] = new MyJson.JsonNode_ValueNumber(sv.scrollWheelFactor);
        json["momentumAmount"] = new MyJson.JsonNode_ValueNumber(sv.momentumAmount);
        json["restrictWithinPanel"] = new MyJson.JsonNode_ValueNumber(sv.restrictWithinPanel);
        json["disableDragIfFits"] = new MyJson.JsonNode_ValueNumber(sv.disableDragIfFits);
        json["smoothDragStart"] = new MyJson.JsonNode_ValueNumber(sv.smoothDragStart);
        json["iOSDragEmulation"] = new MyJson.JsonNode_ValueNumber(sv.iOSDragEmulation);
        return json;
    }
Esempio n. 13
0
	public MyJson.IJsonNode Parser(Component com,NeedList list)
	{
		UIToggle t = com as UIToggle;
		var json = new MyJson.JsonNode_Object();

		if (t.activeSprite != null) {
			json["activeSprite"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.activeSprite.gameObject));
			Debug.Log(t.gameObject + "&&&&&&&&&&&&&&&&&&&&&"+t.activeSprite.gameObject);
		}	 
		//json["activeSprite"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t));
		//json["group"] = new MyJson.JsonNode_ValueNumber(t.group);
		//json["value"] = new MyJson.JsonNode_ValueNumber(t.value);
	//	json ["sprite"] = new MyJson.JsonNode_ValueString (t.activeSprite);
	//	json ["onChange"] = new MyJson.JsonNode_ValueString (t.onChange);
		return json;
	}
Esempio n. 14
0
    public MyJson.IJsonNode Parser(Component com,NeedList list)
    {
        UILabel t = com as UILabel;
        var json = new MyJson.JsonNode_Object();

        //font 有特殊的打包逻辑
        if (t.bitmapFont != null)
        {
            json["bfont"] = new MyJson.JsonNode_ValueString(t.bitmapFont.name);
        }
        else if (t.trueTypeFont != null)
        {
            json["tfont"] = new MyJson.JsonNode_ValueString(t.trueTypeFont.name);
            if(list!=null)
            {
                list.AddDependTFont(t.trueTypeFont.name);

            }
        }
        else
        {
            Debug.LogError("UILabel" + com.name + " 未指定Font");
        }

        json["fontsize"] = new MyJson.JsonNode_ValueNumber(t.fontSize);

        //材质有特殊的打包逻辑
        //json["mate"] = t.material;

        json["text"] = new MyJson.JsonNode_ValueString(t.text);
        json["overflowMethod"] = new MyJson.JsonNode_ValueString(t.overflowMethod.ToString());
        json["alignment"] = new MyJson.JsonNode_ValueString(t.alignment.ToString());
        json["keepCrispWhenShrunk"] = new MyJson.JsonNode_ValueString(t.keepCrispWhenShrunk.ToString());
        json["applyGradient"] = new MyJson.JsonNode_ValueNumber(t.applyGradient);
        json["gradientTop"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.gradientTop));
        json["gradientBottom"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.gradientBottom));
        json["effectStyle"] = new MyJson.JsonNode_ValueString(t.effectStyle.ToString());
        json["effectColor"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.effectColor));
        json["effectDistance"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(t.effectDistance));
        json["spacing"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(new Vector2(t.spacingX, t.spacingY)));
        json["maxLineCount"] = new MyJson.JsonNode_ValueNumber(t.maxLineCount);


        ComponentParser.ParserWidget(json, t);

        return json;
    }
Esempio n. 15
0
    public static string SaveAtlas(UIAtlas atlas, string path,string pathtex)
    {
        if (System.IO.Directory.Exists(path) == false)
        {
            System.IO.Directory.CreateDirectory(path);
        }
        string tname = SaveTexture(atlas.texture, pathtex);

        MyJson.JsonNode_Object obj = new MyJson.JsonNode_Object();

        obj["pixelSize"] = new MyJson.JsonNode_ValueNumber(atlas.pixelSize);
        var jsonmat = new MyJson.JsonNode_Object();
        obj["mat"] = jsonmat;
        jsonmat["shader"] = new MyJson.JsonNode_ValueString(atlas.spriteMaterial.shader.name);
        MyJson.JsonNode_Array shaderparams = new MyJson.JsonNode_Array();
        jsonmat["shaderparam"] = shaderparams;
        foreach (var p in atlas.spriteMaterial.shaderKeywords)
        {
            shaderparams.Add(new MyJson.JsonNode_ValueString(p));
        }

        jsonmat["img"] = new MyJson.JsonNode_ValueString(tname);
        var jsonsparray = new MyJson.JsonNode_Object();
        obj["sprites"] = jsonsparray;
        foreach (var s in atlas.spriteList)
        {
            MyJson.JsonNode_Array sarray = new MyJson.JsonNode_Array();
            jsonsparray[s.name] = sarray;
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.x));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.y));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.width));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.height));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.borderLeft));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.borderRight));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.borderTop));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.borderBottom));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.paddingLeft));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.paddingRight));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.paddingTop));
            sarray.Add(new MyJson.JsonNode_ValueNumber(s.paddingBottom));
        }
        string atalsName = atlas.name.ToLower();
        System.IO.File.WriteAllText(System.IO.Path.Combine(path, atalsName + ".atlas.txt"), obj.ToString());

        return atalsName;
    }
Esempio n. 16
0
    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {

        UIGrid t = com as UIGrid;
        var json = new MyJson.JsonNode_Object();

        json["arrangement"] = new MyJson.JsonNode_ValueString(t.arrangement.ToString());
        json["sorting"] = new MyJson.JsonNode_ValueString(t.sorting.ToString());
        json["pivot"] = new MyJson.JsonNode_ValueString(t.pivot.ToString());
        json["maxPerLine"] = new MyJson.JsonNode_ValueNumber(t.maxPerLine);
        json["cellWidth"] = new MyJson.JsonNode_ValueNumber(t.cellWidth);
        json["cellHeight"] = new MyJson.JsonNode_ValueNumber(t.cellHeight);
        json["animateSmoothly"] = new MyJson.JsonNode_ValueNumber(t.animateSmoothly);
        json["hideInactive"] = new MyJson.JsonNode_ValueNumber(t.hideInactive);
        json["keepWithinPanel"] = new MyJson.JsonNode_ValueNumber(t.keepWithinPanel);

        return json;

    }
Esempio n. 17
0
    public MyJson.IJsonNode Parser(Component com,NeedList list)
    {
        UIPanel t = com as UIPanel;
        var json = new MyJson.JsonNode_Object();

        json["alpha"] = new MyJson.JsonNode_ValueNumber(t.alpha);
        json["depth"] = new MyJson.JsonNode_ValueNumber(t.depth);
        json["clipping"] = new MyJson.JsonNode_ValueString(t.clipping.ToString());
        if(t.clipping!= UIDrawCall.Clipping.None)
        {
            json["offset"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(t.clipOffset));
            json["region"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector4ToString(t.baseClipRegion));
            if(t.clipping== UIDrawCall.Clipping.SoftClip)
            {

                json["softness"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.Vector2ToString(t.clipSoftness));
            }
        }
       
        return json;
    }
Esempio n. 18
0
    public MyJson.IJsonNode Parser(Component com,NeedList list)
    {
        UIButton t = com as UIButton;
        var json = new MyJson.JsonNode_Object();


        json["tweenTarget"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(t.tweenTarget));
        json["dragHighlight"] = new MyJson.JsonNode_ValueNumber(t.dragHighlight);
        json["duration"] = new MyJson.JsonNode_ValueNumber(t.duration);
        json["colorN"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.defaultColor));
        json["colorH"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.hover));
        json["colorP"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.pressed));
        json["colorD"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(t.disabledColor));

            

        json["spriteN"] = new MyJson.JsonNode_ValueString(t.normalSprite);
        json["springH"] = new MyJson.JsonNode_ValueString(t.hoverSprite);
        json["springP"] = new MyJson.JsonNode_ValueString(t.pressedSprite);
        json["springD"] = new MyJson.JsonNode_ValueString(t.disabledSprite);
        json["pixelSnap"] = new MyJson.JsonNode_ValueNumber(t.pixelSnap);
        return json;
    }
Esempio n. 19
0
    public MyJson.IJsonNode Parser(Component com, NeedList needlist)
    {

        UIInput inp = com as UIInput;
        var json = new MyJson.JsonNode_Object();

        if (inp.label != null)
        {
            json["label"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ComponentToID(inp.label.GetComponent<UILabel>()));
        }
        json["value"] = new MyJson.JsonNode_ValueString(inp.value);
        json["savedAs"] = new MyJson.JsonNode_ValueString(inp.savedAs);
        json["activeTextColor"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(inp.activeTextColor));
        json["caretColor"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(inp.caretColor));
        json["selectionColor"] = new MyJson.JsonNode_ValueString(ComponentTypeConvert.ColorToString(inp.selectionColor));
        if (inp.selectOnTab != null)
        {
            json["selectOnTab"] = new MyJson.JsonNode_ValueNumber(GameObjParser.ObjToID(inp.selectOnTab.gameObject));
        }
        json["inputType"] = new MyJson.JsonNode_ValueString(inp.inputType.ToString());
        json["validation"] = new MyJson.JsonNode_ValueString(inp.validation.ToString());
        json["characterLimit"] = new MyJson.JsonNode_ValueNumber(inp.characterLimit);
        return json;
    }
Esempio n. 20
0
    void SaveItem()
    {
        //GameObject setobj = null;//选中的对象
        //bool bUseHashName = true;//是否使用hash作为资源文件名
        //string exportResult = null;//导出结果
        //string exportPath = null;//导出路径
        //bool bUseHashTreeName = false;//是否使用hash作为导出节点名
        //string exportNodeName = "";//导出节点名称

        nodeParser.nodeParser np = new nodeParser.nodeParser();
        np.SaveNode(this.setobj);//先强制使用HashName

        if (System.IO.Directory.Exists(exportPath) == false)
            System.IO.Directory.CreateDirectory(exportPath);
        string respath = System.IO.Path.Combine(exportPath, "resources");
        if (System.IO.Directory.Exists(respath) == false)
            System.IO.Directory.CreateDirectory(respath);

        MyJson.JsonNode_Array indexfile = new MyJson.JsonNode_Array();
        foreach (var f in np.bufs)
        {
            //写入文件
            {
                var file = System.IO.Path.Combine(respath, f.Key);
                System.IO.File.WriteAllBytes(file, f.Value);
            }
            //记录索引
            MyJson.JsonNode_Object indexitem = new MyJson.JsonNode_Object();
            indexitem["Name"] = new MyJson.JsonNode_ValueString("resources/" + f.Key);
            indexitem["Length"] = new MyJson.JsonNode_ValueNumber(f.Value.Length);
            indexfile.Add(indexitem);
        }
        indexfile.Sort((a, b) =>
        {
            return string.Compare(a.asDict()["Name"].AsString(), b.asDict()["Name"].AsString());
        });
        {//保存索引文件
            byte[] indexcode = System.Text.Encoding.UTF8.GetBytes(indexfile.ToString());

            exportResult = exportNodeName;
            if (bUseHashTreeName)
            {
                exportResult = ResLibTool.ComputeHashString(indexcode);
            }
            string outfile = System.IO.Path.Combine(exportPath, exportResult + ".indexlist.txt");

            System.IO.File.WriteAllBytes(outfile, indexcode);
        }

    }
Esempio n. 21
0
        public static MyJson.JsonNode_Object GetMatConfig(Material mat)
        {
            MaterialProperty[] mps = MaterialEditor.GetMaterialProperties(new UnityEngine.Object[] { mat });

            MyJson.JsonNode_Object json = new MyJson.JsonNode_Object();
            json["name"] = new MyJson.JsonNode_ValueString(mat.shader.name);
            if (mps != null && mps.Length > 0)
            {
                MyJson.JsonNode_Object _params = new MyJson.JsonNode_Object();
                json["params"] = _params;
                foreach (var mp in mps)
                {
                    if (mp.flags == MaterialProperty.PropFlags.HideInInspector) continue;

                    MyJson.JsonNode_Object p = new MyJson.JsonNode_Object();

                    _params[mp.name] = p;

                    p["name"] = new MyJson.JsonNode_ValueString(mp.name);
                    p["type"] = new MyJson.JsonNode_ValueString(mp.type.ToString());
                    p["flags"] = new MyJson.JsonNode_ValueString(mp.flags.ToString());
                    if (mp.type == MaterialProperty.PropType.Texture)
                    {
                        p["texdim"] = new MyJson.JsonNode_ValueString(mp.textureDimension.ToString());
                    }
                    if (mp.type == MaterialProperty.PropType.Range)
                    {
                        p["rangex"] = new MyJson.JsonNode_ValueNumber(mp.rangeLimits.x);
                        p["rangey"] = new MyJson.JsonNode_ValueNumber(mp.rangeLimits.y);
                    }
                }
            }
            else
            {
                json["error"] = new MyJson.JsonNode_ValueString("this mat do not have property.");
            }
            return json;
        }
Esempio n. 22
0
        void Obj2Json(GameObject _obj, MyJson.JsonNode_Object _json)
        {
            _json["name"] = new MyJson.JsonNode_ValueString(_obj.name);
            _json["id"] = new MyJson.JsonNode_ValueNumber(_obj.GetInstanceID());
            //遍历填充组件
            MyJson.JsonNode_Array comps = new MyJson.JsonNode_Array();
            _json["components"] = comps;
            foreach (var c in _obj.GetComponents<Component>())
            {
                if (c == null)
                {
                    Debug.LogWarning("got a commponet null.");
                    continue;
                }
                string type = c.GetType().Name.ToLower();
                var _cjson = new MyJson.JsonNode_Object();
                _cjson["type"] = new MyJson.JsonNode_ValueString(type);
                if (componentParsers.ContainsKey(type) == false)
                {
                    Debug.LogWarning("can't find comparser:" + type);
                    continue;
                }

                componentParsers[type].WriteToJson(resmgr, _obj, c, _cjson);
                comps.Add(_cjson);
            }

            //遍历填充树
            if (_obj.transform.childCount > 0)
            {
                MyJson.JsonNode_Array children = new MyJson.JsonNode_Array();
                _json["children"] = children;

                for (int i = 0; i < _obj.transform.childCount; i++)
                {
                    var subobj = _obj.transform.GetChild(i).gameObject;
                    MyJson.JsonNode_Object _subjson = new MyJson.JsonNode_Object();
                    Obj2Json(subobj, _subjson);
                    children.Add(_subjson);
                }
            }

        }
Esempio n. 23
0
    //从Atlas 加载
    public static UIAtlas UIAtlasFromJson(MyJson.JsonNode_Object objJson,string name)
    {
        GameObject _obj = new GameObject();
        _obj.hideFlags = HideFlags.HideInHierarchy;// false;
        _obj.SetActive(false);
        UIAtlas atlas = _obj.AddComponent<UIAtlas>();
        MyJson.JsonNode_Object obj = objJson;
        atlas.name = name;
        atlas.pixelSize = obj["pixelSize"] as MyJson.JsonNode_ValueNumber;
        obj["pixelSize"] = new MyJson.JsonNode_ValueNumber(atlas.pixelSize);
        MyJson.JsonNode_Object jsonmat = obj["mat"] as MyJson.JsonNode_Object;
        string shader = jsonmat["shader"] as MyJson.JsonNode_ValueString;
        List<string> pp = new List<string>();
        foreach (MyJson.JsonNode_ValueString p in jsonmat["shaderparam"] as MyJson.JsonNode_Array)
        {
            pp.Add(p);
        }
        Material mat = new Material(Shader.Find(shader));
        mat.shaderKeywords = pp.ToArray();
        if(jsonmat.ContainsKey("img"))
        {
            string texname =jsonmat["img"] as MyJson.JsonNode_ValueString;
            texname = texname.ToLower();
            var tex = AtlasMgr.Instance.GetTexture(texname);
            if(tex!=null)
            {
                mat.mainTexture = tex;

            }
            else
            {
                Debug.Log("tex:" + texname + " not found");

            }
        }
        else
        {

            Debug.Log("tex   not exist.");

        }
        

        atlas.spriteMaterial = mat;
        MyJson.JsonNode_Object sps = obj["sprites"] as MyJson.JsonNode_Object;
        //jsonmat["img"] = new MyJson.JsonNode_ValueString(tname);
        foreach (var s in sps)
        {
            UISpriteData data = new UISpriteData();
            data.name = s.Key;

            MyJson.JsonNode_Array sarray = s.Value as MyJson.JsonNode_Array;
            data.x = sarray[0] as MyJson.JsonNode_ValueNumber;
            data.y = sarray[1] as MyJson.JsonNode_ValueNumber;
            data.width = sarray[2] as MyJson.JsonNode_ValueNumber;
            data.height = sarray[3] as MyJson.JsonNode_ValueNumber;
            data.borderLeft = sarray[4] as MyJson.JsonNode_ValueNumber;
            data.borderRight = sarray[5] as MyJson.JsonNode_ValueNumber;
            data.borderTop = sarray[6] as MyJson.JsonNode_ValueNumber;
            data.borderBottom = sarray[7] as MyJson.JsonNode_ValueNumber;
            data.paddingLeft = sarray[8] as MyJson.JsonNode_ValueNumber;
            data.paddingRight = sarray[9] as MyJson.JsonNode_ValueNumber;
            data.paddingTop = sarray[10] as MyJson.JsonNode_ValueNumber;
            data.paddingBottom = sarray[11] as MyJson.JsonNode_ValueNumber;
            atlas.spriteList.Add(data);
        }
        return atlas;
    }
Esempio n. 24
0
    static MyJson.IJsonNode UnPackJsonNumber(System.IO.Stream stream, byte tagfirst)
    {
        MyJson.JsonNode_ValueNumber number = new MyJson.JsonNode_ValueNumber();
        bool isFloat = (tagfirst & 32) > 0;
        bool isBool = (tagfirst & 16) > 0;
        bool isNull = (tagfirst & 8) > 0;
        int blen = tagfirst % 8 + 1;
        byte[] buf = new byte[4];
        for (int i = 0; i < 4; i++)
        {
            buf[i] = 0;
        }
        if (isBool)
        {
            number.SetBool(isNull);
        }
        else if (isNull)
        {
            number.SetNull();
        }
        else if (isFloat)
        {
            stream.Read(buf, 0, blen);
            number.value = BitConverter.ToSingle(buf, 0);
        }
        else
        {
            stream.Read(buf, 0, blen);
            number.value = BitConverter.ToInt32(buf, 0);
        }

        return number;
    }
Esempio n. 25
0
        public static MyJson.JsonNode_Object ToJson(object ScriptObject)
        {
            CLRSharp.CLRSharp_Instance sobj = ScriptObject as CLRSharp.CLRSharp_Instance;
            if (sobj == null) return null;
            MyJson.JsonNode_Object obj = new MyJson.JsonNode_Object();
            var stype = sobj.type;
            //    CSLE.SType stype=sobj.type;
            var ms = stype.GetFieldNames();
            foreach (var m in ms)
            {
                var field = stype.GetField(m);
                if (field.isStatic) continue;
                if ((Type)field.FieldType.TypeForSystem == typeof(int))
                {
                    obj[m] = new MyJson.JsonNode_ValueNumber((int)sobj.Fields[m]);
                }
                else if ((Type)field.FieldType.TypeForSystem == typeof(float))
                {
                    obj[m] = new MyJson.JsonNode_ValueNumber((float)sobj.Fields[m]);
                }
                else if ((Type)field.FieldType.TypeForSystem == typeof(double))
                {
                    obj[m] = new MyJson.JsonNode_ValueNumber((double)sobj.Fields[m]);
                }
                else if ((Type)field.FieldType.TypeForSystem == typeof(string))
                {
                    obj[m] = new MyJson.JsonNode_ValueString((string)sobj.Fields[m]);
                }

        //        else if ((Type)m.Value.type.type == typeof(List<object>))
                else if ((Type)field.FieldType.TypeForSystem == typeof(List<CLRSharp.CLRSharp_Instance>))
                {
                    //处理List
                    List<CLRSharp.CLRSharp_Instance> slist = sobj.Fields[m] as List<CLRSharp.CLRSharp_Instance>;
                    var list = new MyJson.JsonNode_Array();
                    obj[m] = list;
                    foreach (var item in slist)
                    {
                        list.Add(ToJson(item));
                    }
                }
                else if ((Type)field.FieldType.TypeForSystem == typeof(List<string>))
                {
                    var list = new MyJson.JsonNode_Array();
                    obj[m] = list;

                    List<string> slist = sobj.Fields[m] as List<string>;

                    foreach (var item in slist)
                    {
                        list.Add(new MyJson.JsonNode_ValueString(item));
                    }
                }
                else if ((Type)field.FieldType.TypeForSystem == typeof(List<int>))
                {
                    var list = new MyJson.JsonNode_Array();
                    obj[m] = list;

                    List<int> slist = sobj.Fields[m] as List<int>;

                    foreach (var item in slist)
                    {
                        list.Add(new MyJson.JsonNode_ValueNumber(item));
                    }
                }
                else if ((Type)field.FieldType.TypeForSystem == typeof(List<float>))
                {
                    var list = new MyJson.JsonNode_Array();
                    obj[m] = list;

                    List<float> slist = sobj.Fields[m] as List<float>;

                    foreach (var item in slist)
                    {
                        list.Add(new MyJson.JsonNode_ValueNumber(item));
                    }
                }
                else if ((Type)field.FieldType.TypeForSystem == typeof(List<double>))
                {
                    var list = new MyJson.JsonNode_Array();
                    obj[m] = list;

                    List<double> slist = sobj.Fields[m] as List<double>;

                    foreach (var item in slist)
                    {
                        list.Add(new MyJson.JsonNode_ValueNumber(item));
                    }
                }
                else if (field.FieldType is CLRSharp.ICLRType_Sharp)
                //        else if ((CSLE.SType)m.Value.type.type != null)//其他嵌套脚本类型
                {
                    obj[m] = ToJson(sobj.Fields[m]);
                }
                else
                {
                    Logger.Log("发现不能处理的类型:" + stype.Name + ":" + m + ":" + field.FieldType.ToString());
                }
            }
            return obj;
        }