private void LogInfo(string msgFormat, params object[] ps) { if (logMessages) { LitLogger.LogFormat(msgFormat, ps); } }
private SerializeEntity TrySerialize(Component comp) { SerializeEntity retSE = null; if (comp is ISerializable) { var sa = comp as ISerializable; retSE = sa.Serialize(); } if (comp is ISerializeEvent) { var se = comp as ISerializeEvent; var ee = se.Serialize(); if (ee != null) { retSE = ee.ToSerializeEntity(); } return(retSE); } if (retSE == null) { retSE = TryCallSerializeByReflection(comp); } if (comp == null) { //TODO 完全通过反射的方式序列化对象 } if (retSE != null && !SerializeReg.HasRegType(retSE.Type) && (!(comp is ISerializeEvent))) { LitLogger.ErrorFormat("{0} not register in SeriaLizeReg,Can'not be Serialized", retSE.Type); retSE = null; } return(retSE); }
public void RegistEvent(EventEntity litEvent) { switch (litEvent.EventType) { case LitEventType.LE_None: LitLogger.ErrorFormat("Register Invalid Event Type {0} , {1}", litEvent.EventType, litEvent.EventParam); break; case LitEventType.LE_UID: RegisterLifeEvent(litEvent); InitUID(litEvent.EventParam); break; case LitEventType.LE_Handler: RegisterLifeEvent(litEvent); InitLuaFile(litEvent.EventParam); break; case LitEventType.LE_InitDisable: InitLitState(litEvent); break; default: InitLifeEvent(litEvent); break; } }
void Start() { float layerValue = Mathf.Log(layer.value, 2); if (layerValue % 1 > 0) { LitLogger.ErrorFormat("LitUIDepth => Set Layer Error {0} , Layer:{1}", gameObject.name, layerValue); } gameObject.layer = (int)layerValue; if (isUI) { Canvas canvas = GetComponent <Canvas>(); if (canvas == null) { canvas = gameObject.AddComponent <Canvas>(); } canvas.overrideSorting = true; canvas.sortingOrder = order; } else { Renderer[] renders = GetComponentsInChildren <Renderer>(); foreach (Renderer render in renders) { render.sortingOrder = order; } if (isAttach <Renderer>()) { var render = GetComponent <Renderer>(); render.sortingOrder = order; } } }
public void Despawn(Transform instance) { bool despawned = false; for (int i = 0; i < this._prefabPools.Count; i++) { if (this._prefabPools[i]._spawned.Contains(instance)) { despawned = this._prefabPools[i].DespawnInstance(instance); break; } else if (this._prefabPools[i]._despawned.Contains(instance)) { LitLogger.WarningFormat("SpawnPool {0}: {1} has already been despawned. " + "You cannot despawn something more than once!", this.poolName, instance.name); return; } } if (!despawned) { Debug.LogError(string.Format("SpawnPool {0}: {1} not found in SpawnPool", this.poolName, instance.name)); return; } this._spawned.Remove(instance); }
private void InitComp(GameObject go, SerializeEntity se) { if (se.Type.StartsWith("LE_")) { InitEventComp(go, se); return; } Type type = SerializeReg.GetType(se.Type); if (type == null) { LitLogger.ErrorFormat("{0} not registe in SerializeReg", se.Type); return; } if (type == typeof(Transform)) { var trans = go.GetComponent <Transform>(); TryDeserializeComp(trans, se); } else { var comp = go.AddComponent(type); TryDeserializeComp(comp, se); } }
public static T GetInstance() { if (_inst == null) { LitLogger.ErrorFormat("{0} Not Init in FaceMgr", typeof(T).Name); } return(_inst); }
private void TrrigerCreateEvent(string poolName) { if (!this.onCreatedDelegates.ContainsKey(poolName)) { LitLogger.WarningFormat("No OnCreatedDelegates found for pool name: <{0}>", poolName); return; } this.onCreatedDelegates[poolName](this[poolName]); }
public void RemoveOnCreatedDelegate(string poolName, OnCreatedDelegate createdDelegate) { if (!this.onCreatedDelegates.ContainsKey(poolName)) { LitLogger.WarningFormat("No OnCreatedDelegates found for pool name: <{0}>", poolName); return; } this.onCreatedDelegates[poolName] -= createdDelegate; }
public void TestDeserialize() { LitLogger.Log("==================="); var so = SerializeObj.Create(strJson); LitDeserializer lder = new LitDeserializer(so, parent); lder.Deserialize(); LitLogger.Log(so.Serialize()); }
public JsonData Get(string name) { if (data == null || !data.Contains(name)) { LitLogger.WarningFormat("Not Found {0} in JsonData {1}", name, data.ToJson()); return(new JsonData()); } return(data[name]); }
private void Awake() { if (_inst != null) { GameObject.DestroyImmediate(_inst); LitLogger.ErrorFormat("Can not Repeat Create {0}", typeof(T).Name); } _inst = this as T; (_inst as SingletonBehaviour <T>).Init(); }
public string Serialize() { JsonData data = ToJsonData(); if (data == null) { LitLogger.LogFormat("Convert To JsonData Error {0}", objName); } return(data.ToJson()); }
internal bool Remove(SpawnPool spawnPool) { if (!this.ContainsKey(spawnPool.poolName)) { LitLogger.WarningFormat(string.Format("Pool not in PoolManager: {0}", spawnPool.poolName)); return(false); } this._pools.Remove(spawnPool.poolName); return(true); }
public static Type GetType(string name) { Type t = null; allSerializeType.TryGetValue(name, out t); if (t == null) { LitLogger.ErrorFormat("The Type not resgister {0}", name); } return(t); }
internal void Add(SpawnPool spawnPool) { if (this.ContainsKey(spawnPool.poolName)) { LitLogger.WarningFormat(string.Format("A pool with the name '{0}' already exists. ", spawnPool.poolName)); return; } this._pools.Add(spawnPool.poolName, spawnPool); TrrigerCreateEvent(spawnPool.name); }
public static void _Swap <T>(this IList <T> lists, int a, int b) { if (!lists._isValidIndex(a) || !lists._isValidIndex(b)) { LitLogger.ErrorFormat("Invalid Index : {0} , {1}", a, b); return; } T tmp = lists[a]; lists[a] = lists[b]; lists[b] = tmp; }
private void InitComps(GameObject go, List <SerializeEntity> comps) { if (comps == null || comps.Count <= 0) { LitLogger.WarningFormat("{0} has no Components to Add", go.name); return; } for (int i = 0; i < comps.Count; i++) { InitComp(go, comps[i]); } }
public static float ToFloat(this string str, float defV = 0) { try { defV = Convert.ToSingle(str); } catch (System.Exception e) { LitLogger.Error(e.Message); } return(defV); }
public static int ToInt(this string str, int defV = 0) { try { defV = Convert.ToInt32(str); } catch (System.Exception e) { LitLogger.Error(e.Message); } return(defV); }
public virtual void GC() { if (_active) { pool.AddLast(this as T); this.OnDisable(); _active = false; } else { LitLogger.ErrorFormat("Obj has been GC <{0}>", this); } }
public void AddChild(SerializeObj so) { if (so == null) { LitLogger.Error("Con'not add null child"); return; } if (childs == null) { childs = new List <SerializeObj>(); } childs.Add(so); }
public void RegisterLifeEvent(EventEntity e) { if (!e.isValid) { LitLogger.ErrorFormat("Invalid Event : {0}", e.ToString()); return; } if (LifeEvents == null) { LifeEvents = new List <EventEntity>(); } LifeEvents.Add(e); }
private static void InitCompsByJsonData(SerializeObj so, JsonData jsonData) { if (so == null || jsonData == null || jsonData.Count <= 0) { LitLogger.ErrorFormat("{0} components is Empty {1}", so.ObjName, jsonData); return; } for (int i = 0; i < jsonData.Count; i++) { var data = jsonData[i]; SerializeEntity se = new SerializeEntity(data); so.AddComp(se); } }
public static void UID_Register(string uid, LitLua obj) { if (uid.isEmpty() || obj == null) { LitLogger.ErrorFormat("Register Invalid UID : <{0}> , <{1}>", uid, obj); } else if (UID_Contains(uid)) { LitLogger.WarningFormat("UID <{0}> repeated !! => {1} will replace by {2}", uid, UID_Get(uid), obj); UIDMap[uid] = obj; } else { UIDMap.Add(uid, obj); } }
public void GenerateEvent(LitEventType type, object sender) { if (type == LitEventType.LE_None || sender == null) { LitLogger.ErrorFormat("Trriger Invalid Event : {0} , {1}", type, sender); return; } var ee = GetEventEntity(type); if (ee != null) { TrrigerEvent te = new TrrigerEvent(ee, sender); curEvent = te; TryHandleEvent(); } }
public SpawnPool this[string key] { get { SpawnPool pool; try { pool = this._pools[key]; } catch (KeyNotFoundException) { LitLogger.WarningFormat("A Pool with the name '{0}' not found. " + "\nPools={1}", key, this.ToString()); return(null); } return(pool); } }
private List <SerializeEntity> GetObjAllComps(GameObject go) { List <SerializeEntity> comps = new List <SerializeEntity>(); var compList = go.GetComponents <Component>(); for (int i = 0; i < compList.Length; i++) { var so = TrySerialize(compList[i]); if (so != null) { comps.Add(so); } else { LitLogger.ErrorFormat("Can'not Serialize Component {0} on {1}", compList[i].GetType().Name, go.name); } } return(comps); }
//public static void SetEnum<T>(ref T value, SerializeEntity data, string name) where T : System.IConvertible //{ // if (data == null || !data.Contains(name)) // return; // int _v = data[name]; // value = T.C; //} #endregion #region "资源处理" public static string GetResPath(Object obj) { if (obj == null) { return(""); } #if UNITY_EDITOR string fullPath = UnityEditor.AssetDatabase.GetAssetPath(obj); int startIndex = fullPath.IndexAtTimes('/', 2) + 1; int endIndex = fullPath.IndexOf("."); if (startIndex < 0 || endIndex < 0 || startIndex >= endIndex) { LitLogger.WarningFormat("Not Found Res {0}", obj); return(""); } return(fullPath.Substring(startIndex, endIndex - startIndex)); #endif return(""); }
public override void OnInspectorGUI() { litSerObj.Update(); base.OnInspectorGUI(); GUILayout.Space(20); if (GUILayout.Button("Generate LitObjs")) { if (target is LitGenerator) { var genterator = target as LitGenerator; genterator.Generate(); } else { LitLogger.Error("Generate Error"); } } litSerObj.Apply(); }