public void GetBindingInfoToJson() { if (QConfigure.selectTransform == null) { return; } JsonData jd = new JsonData(); foreach (var item in dic) { if (!item.Value.state.isVariable) { continue; } VariableJson vj = new VariableJson(); var state = item.Value.state; vj.isOpen = state.isOpen; vj.isAttribute = state.isAttribute; vj.isEvent = state.isEvent; vj.isVariable = state.isVariable; vj.index = state.index; vj.name = item.Value.name; vj.type = item.Value.type; vj.findPath = QGlobalFun.GetGameObjectPath(item.Key, QConfigure.selectTransform); jd.Add(JsonMapper.ToObject(JsonMapper.ToJson(vj))); } QFileOperation.WriteText(QConfigure.GetInfoPath(), jd.ToJson()); }
public QVariableModel(Transform t) { target = t; path = QGlobalFun.GetGameObjectPath(t, Selection.activeTransform); type = GetUIType(); name = GetName(string.Format("{0}_{1}", type, t.name), t); state.SetIndex(type, t); OnTypeChanged(type); state.onTypeChanged = OnTypeChanged; }
private void GetBindingInfo() { QScriptInfo so; if (QFileOperation.IsExists(QConfigure.InfoPath)) { so = AssetDatabase.LoadAssetAtPath <QScriptInfo>(QConfigure.InfoPath); } else { so = ScriptableObject.CreateInstance <QScriptInfo>(); } List <string> k = new List <string>(dic.Count); List <string> t = new List <string>(dic.Count); List <string> p = new List <string>(dic.Count); foreach (var key in dic.Keys) { var target = dic[key]; if (target.state.isVariable) { k.Add(target.name); t.Add(target.type.ToString()); p.Add(QGlobalFun.GetGameObjectPath(key, QConfigure.selectTransform)); } } int count = k.Count; var infos = new QScriptInfo.FieldInfo[count]; for (int i = 0; i < count; i++) { infos[i] = new QScriptInfo.FieldInfo(); infos[i].name = k[i]; infos[i].type = t[i]; infos[i].path = p[i]; } so.SetClassInfo(QConfigure.UIName, infos); if (QFileOperation.IsExists(QConfigure.InfoPath)) { AssetDatabase.SaveAssets(); } else { if (QFileOperation.IsDirctoryName(QConfigure.InfoPath, true)) { AssetDatabase.CreateAsset(so, QConfigure.InfoPath); } } }