public string getStateSprite(WXHierarchyContext context, UISprite uiSprite, string spriteName) { string uuid = WXSpriteFrame.getSprite(uiSprite.atlas as UIAtlas, spriteName, context.preset); context.AddResource(uuid); return(uuid); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); if (this.collider != null) { data.AddField("convex", this.collider.convex); data.AddField("isTrigger", this.collider.isTrigger); data.AddField("cookingOptions", (int)this.collider.cookingOptions); data.AddField("material", new WXPhysicsMaterial(this.collider.material).ToJSON()); Mesh mesh = this.collider.sharedMesh; if (mesh != null) { WXMesh meshConverter = new WXMesh(mesh); string meshPath = meshConverter.Export(context.preset); data.AddField("mesh", meshPath); context.AddResource(meshPath); } } return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", "UITextInput"); JSONObject subJSON = new JSONObject(JSONObject.Type.OBJECT); if (uiInput.label) { subJSON.AddField("label", context.AddComponentInProperty(new WXUILabel(uiInput.label, gameObject, entity), uiInput.label)); } WXUIMask mask = new WXUIMask(); WXUIGraphic graphic = new WXUIGraphic(0); WXKeyboardInputComponent keyboardInput = new WXKeyboardInputComponent(this.uiInput, gameObject, entity); entity.components.Add(context.AddComponent(keyboardInput, null)); entity.components.Add(context.AddComponent(mask, null)); entity.components.Add(context.AddComponent(graphic, null)); subJSON.AddField("maxChars", uiInput.characterLimit); subJSON.AddField("active", this.uiInput.enabled); json.AddField("data", subJSON); return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); UIScrollView.ShowCondition showScrollBars = uiScrollView.showScrollBars; data.AddField("showScrollBars", (int)showScrollBars); var horizontalScrollBar = (UIScrollBar)uiScrollView.horizontalScrollBar; if (horizontalScrollBar != null) { data.AddField("horizontalScrollBar", context.AddComponent(new WXUIScrollBarScript(horizontalScrollBar, go, entity), horizontalScrollBar)); } var verticalScrollBar = (UIScrollBar)uiScrollView.verticalScrollBar; if (verticalScrollBar != null) { data.AddField("verticalScrollBar", context.AddComponent(new WXUIScrollBarScript(verticalScrollBar, go, entity), verticalScrollBar)); } data.AddField("ref", context.AddComponent(new WXUIScrollView(uiScrollView, go, entity), uiScrollView)); return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); JSONObject res_paths_json = new JSONObject(JSONObject.Type.ARRAY); data.AddField("resources", res_paths_json); foreach (Object file in collection_.ResourceFiles) { if (file != null) { string file_path = AssetDatabase.GetAssetPath(file.GetInstanceID()); WXRawResource resourceConverter = new WXRawResource(file_path); string ret_path = resourceConverter.Export(context.preset); if (ret_path != "") { res_paths_json.Add(ret_path); context.AddResource(ret_path); } } } return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); if (this.collider != null) { data.AddField("isTrigger", this.collider.isTrigger); data.AddField("material", new WXPhysicsMaterial(this.collider.material).ToJSON()); JSONObject center = new JSONObject(JSONObject.Type.ARRAY); center.Add(this.collider.center.x); center.Add(this.collider.center.y); center.Add(this.collider.center.z); data.AddField("center", center); JSONObject size = new JSONObject(JSONObject.Type.ARRAY); size.Add(this.collider.size.x); size.Add(this.collider.size.y); size.Add(this.collider.size.z); data.AddField("size", size); } return(json); }
public string getStateSprite(WXHierarchyContext context, Sprite uiSprite) { string uuid = WXUGUISpriteFrame.getSprite(uiSprite, context.preset); context.AddResource(uuid); return(uuid); }
protected override JSONObject ToJSON(WXHierarchyContext context) { var a = JsonUtility.ToJson(uiAnchor, true); JSONObject json = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", "UIAnchor"); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); data.AddField("side", uiAnchor.side.ToString()); JSONObject pixelOffset = new JSONObject(JSONObject.Type.ARRAY); pixelOffset.Add(uiAnchor.pixelOffset.x); pixelOffset.Add(uiAnchor.pixelOffset.y); data.AddField("pixelOffset", pixelOffset); JSONObject relativeOffset = new JSONObject(JSONObject.Type.ARRAY); relativeOffset.Add(uiAnchor.relativeOffset.x); relativeOffset.Add(uiAnchor.relativeOffset.y); data.AddField("relativeOffset", relativeOffset); json.AddField("data", data); return(json); }
// inner recursion method, thus each if-statement must have @return in the end of the following block. private static JSONObject innerHandleField(Type type, object value, WXHierarchyContext context, List <string> requireList) { // 因为下方有递归尝试转换基类的逻辑,这里需要有一个终结点 if (type == typeof(System.Object)) { return(null); } if (WXMonoBehaviourExportHelper.IsInBlackList(type)) { return(null); } foreach (ConditionPropertiesHandler handler in conditionPropertiesHandlerList) { if (handler.condition.Invoke(type)) { JSONObject result = handler.handler.Invoke(type, value, context, requireList); if (result != null) { return(result); } } } // 尝试转换它的基类 return(innerHandleField(type.BaseType, value, context, requireList)); }
/** * 遍历加入时的回调hook */ public void OnIterateTo(WXHierarchyContext context) { // ToJSON阶段有可能还会增加component,会违反c#的遍历限制。 // 所以不能在最终计算节点树json的时候做这个事情。 // 只能在这时候做。 json = ToJSON(context); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); data.AddField("barSize", (float)uiScrollBar.barSize); data.AddField("value", (float)uiScrollBar.value); data.AddField("alpha", (float)uiScrollBar.alpha); data.AddField("fillDirection", (int)uiScrollBar.fillDirection); if (uiScrollBar.foregroundWidget != null) { var foregroundWidget = new WXUISprite(uiScrollBar.foregroundWidget as UISprite, go, entity); data.AddField("foregroundWidget", context.AddComponent( foregroundWidget, uiScrollBar.foregroundWidget )); } if (uiScrollBar.backgroundWidget != null) { var backgroundWidget = new WXUISprite(uiScrollBar.backgroundWidget as UISprite, go, entity); data.AddField("backgroundWidget", context.AddComponent( backgroundWidget, uiScrollBar.backgroundWidget )); } return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); // if (this.collider != null) { data.AddField("isTrigger", this.isTrigger); if (material != null) { WXPhysicsMaterial materialConverter = new WXPhysicsMaterial(material); string materialPath = materialConverter.Export(context.preset); if (materialPath != null && materialPath != "") { data.AddField("material", materialPath); context.AddResource(materialPath); } } JSONObject center = new JSONObject(JSONObject.Type.ARRAY); center.Add(-this.center.x); center.Add(this.center.y); center.Add(this.center.z); data.AddField("center", center); data.AddField("radius", this.radius); } return(json); }
private static void GetGameObjectReferenceIndex(WXHierarchyContext context, GameObject go, ref JSONObject innerData, bool isGameObject = true) { if (WXBridge.isNGUIPreset) { // ngui hack innerData = JSONObject.Create(context.AddComponentInProperty( (WXComponent)Activator.CreateInstance(Type.GetType("WXEngine.WXTransform2DComponent"), (object)go.transform), go.transform) ); return; } if (WXBridge.isUGUIPreset) { // ugui hack innerData = JSONObject.Create((int)context.AddComponent( (WXComponent)Activator.CreateInstance(Type.GetType("WXEngine.WXUGUITransform2DComponent"), (object)go.transform), go.transform) ); return; } if (isGameObject) { innerData.AddField("type", "UnityEngine.GameObject".EscapeNamespaceSimple()); innerData.AddField("value", context.AddComponentInProperty(new WXTransform3DComponent(go.transform), go.transform)); // temp impl: add the referring engine.transform3D index } else { innerData.AddField("value", context.AddComponentInProperty(new WXUnityComponent(go.transform), go.transform)); } }
protected override JSONObject ExportResource(ExportPreset preset) { WXHierarchyContext hierarchyContext = new WXHierarchyContext(preset, prefabPath); // 初始化输出的JSON对象 JSONObject prefabJSONObject = new JSONObject(JSONObject.Type.OBJECT); JSONObject metaJson = new JSONObject(JSONObject.Type.OBJECT); prefabJSONObject.AddField("meta", metaJson); // 填充meta metaJson.AddField("name", exportName); metaJson.AddField("type", /*WXBeefBall.HierarchyType == WXBeefBall.EHierarchyType.TwoD ? "2D" : */ "3D"); JSONObject configJson = new JSONObject(JSONObject.Type.OBJECT); metaJson.AddField("config", configJson); //if (WXBeefBall.HierarchyType == WXBeefBall.EHierarchyType.TwoD) //{ // JSONObject resolutionJson = new JSONObject(JSONObject.Type.ARRAY); // resolutionJson.Add(1280); // resolutionJson.Add(720); // configJson.AddField("resolution", resolutionJson); //} // 开始遍历 WXEntity rootEntity = /*WXBeefBall.HierarchyType == WXBeefBall.EHierarchyType.TwoD ? * hierarchyContext.Iterate2DGameObject(prefabRoot) : * hierarchyContext.Iterate3DGameObject(prefabRoot);*/hierarchyContext.IterateGameObject(prefabRoot, null); prefabJSONObject.AddField("gameObjectList", hierarchyContext.GetGameObjectListJSON()); prefabJSONObject.AddField("componentList", hierarchyContext.GetComponentListJSON()); JSONObject editorInfo = new JSONObject(JSONObject.Type.OBJECT); editorInfo.AddField("assetVersion", 2); prefabJSONObject.AddField("editorInfo", editorInfo); Debug.Log("Export Prefab " + prefabPath + " " + hierarchyContext.resourceList.Count); //WXResourceStore.AddJSONResource( // prefabPath, // "prefab", // prefabJSONObject, // metadata, // hierarchyContext.resourceList, // assetVersion // //AssetDatabase.GetAssetDependencyHash(prefabPath).ToString() //); //return prefabPath; foreach (string resource in hierarchyContext.resourceList) { AddDependencies(resource); } return(prefabJSONObject); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); if (camera != null) { data.AddField("cullingMask", camera.cullingMask); data.AddField("depth", camera.depth); if (camera.orthographic) // 正交 { data.AddField("projectionType", 1); data.AddField("orthographicSize", camera.orthographicSize); } else // 透视 { data.AddField("projectionType", 0); data.AddField("fieldOfView", camera.fieldOfView); } data.AddField("aspect", camera.aspect); data.AddField("nearClipPlane", camera.nearClipPlane); data.AddField("farClipPlane", camera.farClipPlane); RenderTexture targetTexture = camera.targetTexture; if (targetTexture != null) { Debug.LogError("WX Tool targetTexture didn`t null ,now don`t support"); } } return(json); }
private static JSONObject GetPrefabOnSerializedField(WXHierarchyContext context, GameObject go, JSONObject innerData, bool isGameObject = true, Component comp = null) { // Prefab? var path = AssetDatabase.GetAssetPath(go); if (go.transform.IsChildOf(context.Root.transform) || path == "") { GetGameObjectReferenceIndex(context, go, ref innerData, isGameObject); return(innerData); } if (!WXMonoBehaviourExportHelper.exportedResourcesSet.Contains(go)) { WXMonoBehaviourExportHelper.exportedResourcesSet.Add(go); WXPrefab converter = new WXPrefab(go, path); string prefabPath = converter.Export(ExportPreset.GetExportPreset("prefab")); context.AddResource(prefabPath); } var prefabInfo = new JSONObject(JSONObject.Type.OBJECT); var typeName = comp ? comp.GetType().FullName : "UnityEngine.GameObject"; var escapedTypeName = WXMonoBehaviourExportHelper.EscapeNamespace(typeName); prefabInfo.AddField("type", escapedTypeName); prefabInfo.AddField("path", path); innerData.AddField("type", "UnityPrefabWrapper"); innerData.AddField("value", prefabInfo); return(innerData); // GetGameObjectReferenceIndex(context, go, ref innerData, isGameObject); // return innerData; }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); { data.AddField("slopeLimit", this.slopeLimit); data.AddField("stepOffet", this.stepOffset); data.AddField("skinWidth", this.skinWidth); data.AddField("minMoveDistane", this.minMoveDistance); JSONObject center = new JSONObject(JSONObject.Type.ARRAY); center.Add(-this.center.x); center.Add(this.center.y); center.Add(this.center.z); data.AddField("center", center); data.AddField("radius", this.radius); data.AddField("height", this.height); } return(json); }
public static JSONObject InvokePropertyHandler(Type type, object obj, WXHierarchyContext context) { if (propertiesHandlerDictionary.ContainsKey(type) && obj != null) { return(propertiesHandlerDictionary[type](obj, context)); } return(null); }
// public void init (WXBeefBallHierarchyContext context) { // // 添加控制父节点 // WXBeefBallEntity scrollViewControllerEntity = context.CreateEntity(null); // scrollViewControllerEntity.isExtraEntity = false; // scrollViewControllerEntity.isNguiChild = true; // WXBBTransform2DComponent transformController = new WXBBTransform2DComponent(gameObj.transform); // WXBBUIScrollViewController scrollViewController = new WXBBUIScrollViewController(uiScrollView, gameObj, transformController); // scrollViewControllerEntity.components.Add(context.addComponent(scrollViewController, null)); // WXBeefBallTouchInputComponent touchInput = new WXBeefBallTouchInputComponent(gameObj, null); // scrollViewControllerEntity.components.Add(context.addComponent(touchInput, null)); // // 蒙版区域 // WXBBUIMask mask = new WXBBUIMask(); // WXBBUIGraphic graphic = new WXBBUIGraphic(0); // scrollViewControllerEntity.components.Add(context.addComponent(mask, null)); // scrollViewControllerEntity.components.Add(context.addComponent(graphic, null)); // // 内容区域矫正 // UIPanel uiPanel = gameObj.GetComponent(typeof(UIPanel)) as UIPanel; // if ((UnityEngine.Object)uiPanel != (UnityEngine.Object)null) // { // Vector4 offSet = uiPanel.clipOffset; // Vector2 center = uiPanel.baseClipRegion; // transform.size[0] = uiPanel.width; // transform.size[1] = uiPanel.height; // transform.setPosition(-((float)offSet.x + (float)center.x), -((float)offSet.y + (float)center.y)); // } // scrollViewControllerEntity.components.Add(context.addComponent(transformController, null)); // // 修改父子关系 // scrollViewControllerEntity.parent = entity.parent; // entity.parent = scrollViewControllerEntity; // } protected override JSONObject ToJSON(WXHierarchyContext context) { entity.components.Add(context.AddComponent(new WXTouchInputComponent(null, gameObject, entity), null)); entity.components.Add(context.AddComponent(new WXUIMask(), null)); entity.components.Add(context.AddComponent(new WXUIGraphic(0), null)); JSONObject json = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", "UIScrollView"); JSONObject subJSON = new JSONObject(JSONObject.Type.OBJECT); UIScrollView.Movement movement = uiScrollView.movement; subJSON.AddField("movement", (int)movement); bool disableDragIfFits = uiScrollView.disableDragIfFits; subJSON.AddField("disableDragIfFits", (bool)disableDragIfFits); UIPanel uiPanel = gameObject.GetComponent(typeof(UIPanel)) as UIPanel; if ((UnityEngine.Object)uiPanel != (UnityEngine.Object)null) { Vector4 offSet = uiPanel.clipOffset; Vector2 center = uiPanel.baseClipRegion; subJSON.AddField("offSetX", (float)offSet.x); subJSON.AddField("offSetY", (float)offSet.y); subJSON.AddField("centerX", (float)center.x); subJSON.AddField("centerY", (float)center.y); } UIWidget.Pivot contentPivot = uiScrollView.contentPivot; float cellAlignmentX = ( contentPivot == UIWidget.Pivot.Left || contentPivot == UIWidget.Pivot.TopLeft || contentPivot == UIWidget.Pivot.BottomLeft ) ? 0.0f : (( contentPivot == UIWidget.Pivot.Center || contentPivot == UIWidget.Pivot.Top || contentPivot == UIWidget.Pivot.Bottom) ? 0.5f : 1.0f); float cellAlignmentY = ( contentPivot == UIWidget.Pivot.Bottom || contentPivot == UIWidget.Pivot.BottomLeft || contentPivot == UIWidget.Pivot.BottomRight ) ? 0.0f : (( contentPivot == UIWidget.Pivot.Left || contentPivot == UIWidget.Pivot.Center || contentPivot == UIWidget.Pivot.Right) ? 0.5f : 1.0f); subJSON.AddField("cellAlignmentX", cellAlignmentX); subJSON.AddField("cellAlignmentY", cellAlignmentY); json.AddField("data", subJSON); return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); data.AddField("transition", (int)button.transition); // 0-3 JSONObject onClickList = new JSONObject(JSONObject.Type.ARRAY); data.AddField("onClickList", onClickList); int count = button.onClick.GetPersistentEventCount(); for (int i = 0; i < count; i++) { var __onClick = new JSONObject(JSONObject.Type.OBJECT); var target = button.onClick.GetPersistentTarget(i); var targetType = target.GetType().ToString(); __onClick.AddField("targetType", targetType); if (targetType == "UnityEngine.GameObject") { GameObject _go = (GameObject)target; __onClick.AddField("target", WXUIUCommonScript.AddComponent(_go, entity, context)); } else { //todo 其他类型的到时候再考虑 MonoBehaviour _target = (MonoBehaviour)target; __onClick.AddField("target", context.AddComponent(new WXEngineMonoBehaviour(_target), _target)); } __onClick.AddField("method", button.onClick.GetPersistentMethodName(i)); onClickList.Add(__onClick); } JSONObject scriptList = WXUIUCommonScript.AddInteractionScript(go, entity, context, false); data.AddField("scriptList", scriptList); var graphic = button.targetGraphic; if (button.targetGraphic != null) { int idf = context.AddComponent(new WXUIUGraphicScript(graphic, go, entity), graphic); data.AddField("graphic", idf); entity.components.Add(idf); } data.AddField("ref", context.AddComponent(new WXUIUButton(button, go, entity), button)); return(json); }
public string HandleAnimationClip(WXHierarchyContext context, AnimationClip animationClip) { string uid = new WXAnimationClip(animationClip).Export(context.preset); // 因为AnimationClip没走AddFile,这里要手动加dependenices //WXBeefBallExportContext.instance.keys.Add(uid, true); context.AddResource(uid); return(uid); }
protected override JSONObject ExportResource(ExportPreset preset) { hierarchyContext = new WXHierarchyContext(preset, scenePath); // 初始化输出的JSON对象 JSONObject sceneJSONObject = new JSONObject(JSONObject.Type.OBJECT); JSONObject metaJson = new JSONObject(JSONObject.Type.OBJECT); sceneJSONObject.AddField("meta", metaJson); // 填充meta metaJson.AddField("name", exportName); metaJson.AddField("type", /*WXBeefBall.HierarchyType == WXBeefBall.EHierarchyType.TwoD ? "2D" : */ "3D"); JSONObject configJson = new JSONObject(JSONObject.Type.OBJECT); metaJson.AddField("config", configJson); JSONObject lightJson = new JSONObject(JSONObject.Type.OBJECT); GetLightConfig(lightJson, hierarchyContext); configJson.AddField("light", lightJson); GameObject[] root = gameScene.GetRootGameObjects(); // WXEntity rootObj = hierarchyContext.MakeEntity(null); // rootObj.active = true; // rootObj.name = "Scene<" + exportName + ">"; // rootObj.components.Add(hierarchyContext.AddComponent(new WXTransform3DComponent(null, true), null)); foreach (GameObject obj in root) { if ((preset.exportConfigs as HierarchyExportConfig).ignoreNonActive && (!obj.activeSelf || !obj.activeInHierarchy) ) { continue; } obj.name = "Scene<" + exportName + ">"; // 开始遍历 WXEntity leafEntity = hierarchyContext.IterateGameObject(obj); } sceneJSONObject.AddField("gameObjectList", hierarchyContext.GetGameObjectListJSON()); sceneJSONObject.AddField("componentList", hierarchyContext.GetComponentListJSON()); foreach (string resource in hierarchyContext.resourceList) { AddDependencies(resource); } JSONObject editorInfo = new JSONObject(JSONObject.Type.OBJECT); editorInfo.AddField("assetVersion", 2); sceneJSONObject.AddField("editorInfo", editorInfo); return(sceneJSONObject); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); if (toggle.group) { var addComp = new WXUIUToggleGroup(toggle.group, go, entity); data.AddField("toggleGroup", context.AddComponent( addComp, toggle.group )); } JSONObject onValueChangedList = new JSONObject(JSONObject.Type.ARRAY); data.AddField("onValueChanged", onValueChangedList); int onChangeCount = toggle.onValueChanged.GetPersistentEventCount(); for (int i = 0; i < onChangeCount; i++) { var __onChange = new JSONObject(JSONObject.Type.OBJECT); var target = toggle.onValueChanged.GetPersistentTarget(i); var targetType = target.GetType().ToString(); __onChange.AddField("targetType", targetType); if (targetType == "UnityEngine.GameObject") { GameObject _go = (GameObject)target; __onChange.AddField("target", WXUIUCommonScript.AddComponent(_go, entity, context)); } else { //todo 其他类型的到时候再考虑 MonoBehaviour _target = (MonoBehaviour)target; __onChange.AddField("target", context.AddComponent(new WXEngineMonoBehaviour(_target), _target)); } __onChange.AddField("method", toggle.onValueChanged.GetPersistentMethodName(i)); onValueChangedList.Add(__onChange); } JSONObject scriptList = WXUIUCommonScript.AddInteractionScript(go, entity, context, false); data.AddField("scriptList", scriptList); data.AddField("ref", context.AddComponent(new WXUIUToggle(toggle, go, entity), toggle)); return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("__uuid", this.__uuid); return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", this.getTypeName()); JSONObject subJSON = new JSONObject(JSONObject.Type.OBJECT); json.AddField("data", subJSON); return(json); }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", "KeyboardInputComponent"); JSONObject subJSON = new JSONObject(JSONObject.Type.OBJECT); subJSON.AddField("active", !uiInput.readOnly); json.AddField("data", subJSON); return(json); }
public static void Handle(Type type, WXHierarchyContext context, Component comp, JSONObject data, object[] info = null) { if (refComponentsDict.ContainsKey(type)) { refComponentsDict[type](context, comp, data, info); } else { data.AddField("ref", -1); // means not impl Debug.LogError("Unsupport Type: " + type.FullName + " in " + comp.gameObject.name); } }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); if (audio != null && audio.clip != null) { AudioClip clip = audio.clip; // var clipResource = new WXBeefBallAudioClip(clip); // var path = clipResource.Export(); // if (!path.Equals("")) { // context.AddResource(path); // } var path = AssetDatabase.GetAssetPath(clip); //string copyToPath = Path.Combine(WXResourceStore.storagePath, path); path = new WXRawResource(path).Export(context.preset); context.AddResource(path); //string subpath = path; //if (subpath.StartsWith("Assets")) //{ // subpath = path.Substring(6); //} //#if UNITY_EDITOR_WIN //string fromPath = Application.dataPath + "\\" + subpath; //#else //string fromPath = Application.dataPath + "/" + subpath; //#endif //try //{ // wxFileUtil.CopyFile(fromPath, copyToPath); //} //catch (Exception e1) //{ // Debug.Log(e1); //} data.AddField("action", true); data.AddField("_clip", path); data.AddField("_mute", this.audio.mute); data.AddField("_playOnAwake", this.audio.playOnAwake); data.AddField("_loop", this.audio.loop); data.AddField("_volume", this.audio.volume); } return(json); }
public static JSONObject HandleField(FieldInfo field, Component obj, WXHierarchyContext context, List <string> requireList) { try { return(innerHandleField(field.FieldType, field.GetValue(obj), context, requireList)); } catch (Exception e) { Debug.LogErrorFormat("导出节点{0}组件{1}属性{2}时错误", obj.name, obj.GetType().Name, field.Name); Debug.LogException(e); return(null); } }
protected override JSONObject ToJSON(WXHierarchyContext context) { JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); json.AddField("type", getTypeName()); json.AddField("data", data); data.AddField("active", true); WXEngineRefComponentsHandler.Handle(comp.GetType(), context, this.comp, data, this.info); return(json); }