public static void DoLogs(Object context) { // Examples of DLog.Log() DLog.Log("Log a message"); DLog.Log("Log a message with a specific color", Color.blue); DLog.Log("Log a message with a user-defined color", new Color(0f, 0.5f, 0f)); // Examples of DLog.LogWarning() DLog.LogWarning("Log a warning message"); DLog.LogWarning("Log a warning message with a specific color", Color.yellow); DLog.LogWarning("Log a warning message with a user-defined color", new Color(1f, 0.5f, 0.25f)); // Examples of DLog.LogError() DLog.LogError("Log an error message"); DLog.LogError("Log an error message with a specific color", Color.red); DLog.LogError("Log an error message with a user-defined color", new Color(1f, 0f, 1f)); // Examples of DLog.LogException() DLog.LogException(new System.Exception("Log an exception message")); DLog.LogException(new System.Exception("Log an exception message with a specific color"), Color.red); DLog.LogException(new System.Exception("Log an exception message with a user-defined color"), new Color(1f, 0f, 1f)); // Examples of logging With Context DLog.Log("Log a message with a context", context); DLog.Log("Log a message with a specific color and context", Color.green, context); DLog.LogWarning("Log a warning message with a context", context); DLog.LogWarning("Log a warning message with a specific color and context", Color.cyan, context); DLog.LogError("Log an error message with a context", context); DLog.LogError("Log an error message with a specific color and context", Color.red, context); DLog.LogException(new System.Exception("Log an exception message with a context"), context); DLog.LogException(new System.Exception("Log an exception message with a specific color and context"), Color.red, context); }
private void NotifyModifierDetachment(Modifier m) { try { if (OnDetachModifier != null) { OnDetachModifier(m); } } catch (Exception e) { DLog.LogException(e); } }
private void NotifyConsume(SkillId skillId, params Resource.Name[] names) { try { PostSkillConsumeResourceEventHandler?.Invoke(this, new SkillConsumeResourceArgs() { SkillId = skillId, Name = names }); } catch (Exception e) { DLog.LogException(e); } }
private void Notify(Skill skill, SkillId skillId) { try { if (PostSkillCastEventHandler != null) { PostSkillCastEventHandler(this, new SkillCastEventArgs() { skillId = skillId, skill = skill }); } } catch (Exception e) { DLog.LogException(e); } }
private void DisableGameObjects() { if (info.InvisibleModifierConfig.AreAnyGameObjectShouldBeDisabled()) { string[] names = info.InvisibleModifierConfig.ListAffectedGameObjectsName(); for (int kIndex = 0; kIndex < names.Length; kIndex++) { try { gameObjectComponent.GameObject.transform.FindDeepChild(names[kIndex]) .gameObject.SetActive(false); } catch (Exception e) { DLog.LogException(e); } } } }
private void DestroyProjectiles() { for (int kIndex = 0; kIndex < projectiles.Count; kIndex++) { ProjectileComponent p = projectiles[kIndex]; try { if (p.IsDestroyed) { continue; } ((ProjectileGameObjectComponent)p.Entity.GetComponent <EntityGameObjectComponent>()).Destroy(); p.Destroy(); } catch (Exception e) { DLog.LogException(e); } } }
private void CheckIfProjectileGameObjectIsInstantiated(Character caster, Skill parentSkill, Entity entity) { if (entity.GetComponent <EntityGameObjectComponent>().GameObject != null) { return; } try { SkillId skillId = null; caster.SkillId(parentSkill, ref skillId); DLog.LogError(string.Format( "Cannot create GameObject for projectile of skill '{0}'. Maybe prefab path hasn't been configured properly", skillId )); } catch (Exception e) { DLog.LogException(e); } }
protected void Trigger(BaseEvent be, TemplateArgs args = null) { try { if (!IsEventTriggerable(be)) { return; } BaseAction ba = be.ShowAction(); ActionType actionType = ba.ShowActionType(); switch (actionType) { case ActionType.CastProjectile: case ActionType.Impact: List <ProjectileComponent> justLaunchedProjectiles = LaunchProjectiles(be); projectiles.AddRange(justLaunchedProjectiles); break; default: Loopable loopable = loopableElementFactory.Produce( caster, this, config.ShowSkillId(), be, config.ShowSkillCastingSource(), args ); loopableElements.Insert(0, loopable); if (actionType == ActionType.Jump) { jumps.Add((Jump)loopable); } OnLoopableElementProduction(be, loopable); break; } } catch (Exception e) { Exception ex = new Exception("Error trigger event of skill id " + config.ShowSkillId(), e); DLog.LogException(ex); } }
private void ProcessVfx(float dt) { for (int i = pendingVfxs.Count - 1; i >= 0; i--) { try { VfxConfig vc = pendingVfxs[i]; if (elapsed >= FrameAndSecondsConverter._30Fps.FramesToSeconds(vc.frame)) { pendingVfxs.RemoveAt(i); VfxLogic logic = null; VfxAction.VfxType vfxType = vc.vfx.ShowVfxType(); switch (vfxType) { case VfxAction.VfxType.SpawnPrefab: SpawnPrefabVfx spv = (SpawnPrefabVfx)vc.vfx; VfxTag vfxTag = spv.ShowVfxPrefab().GetComponent <VfxTag>(); if (vfxTag) { if (vfxTag.tag == VfxTag.Tag.Startup) { if (isOverrideMode && isOverridingModifierOfSameType) { //DLog.Log("Skip spawn startup vfx"); continue; } if (!isStartupVfxPlayed) { startupVfxCoroutine = Timing.RunCoroutine(LoopStartupVfx_()); } isStartupVfxPlayed = true; //DLog.Log("Spawn startup vfx"); startupVfxLogics.Add(new SpawnPrefab( vc.ttl, (SpawnPrefabVfx)vc.vfx, new Vfx.DefaultVfxGameObjectFactory(environment), target, SkillCastingSource.FromUserInput(), environment.GetCamera(), environment, null )); continue; } } logic = new SpawnPrefab( vc.ttl, (SpawnPrefabVfx)vc.vfx, new Vfx.DefaultVfxGameObjectFactory(environment), target, SkillCastingSource.FromUserInput(), environment.GetCamera(), environment, null ); OnVfxPrefabSpawn((SpawnPrefab)logic); break; case VfxAction.VfxType.ChangeMaterial: logic = new ChangeMaterial( (VfxAction.ChangeMaterialVfx)vc.vfx, vc.ttl, environment, target ); break; case VfxAction.VfxType.ChangeMaterialColor: logic = new ChangeMaterialColor( (VfxAction.ChangeMaterialColorVfx)vc.vfx, vc.ttl, environment, target ); break; case VfxAction.VfxType.AddMaterial: logic = new AddMaterialLogic( (VfxAction.AddMaterialVfx)vc.vfx, vc.ttl, target ); break; default: throw new Exception("Missing logic to create vfx logic of type " + vfxType); } vfxLogics.Add(logic); } } catch (Exception e) { DLog.LogException(e); } } for (int i = vfxLogics.Count - 1; i >= 0; i--) { vfxLogics[i].Update(dt); if (vfxLogics[i].IsFinish()) { vfxLogics.RemoveAt(i); } } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { /*foreach (string str in importedAssets) * { * Debug.Log("Reimported Asset: " + str); * } * foreach (string str in deletedAssets) * { * Debug.Log("Deleted Asset: " + str); * } * * foreach (string str in movedAssets) { * DLog.Log("Moved asset: " + str); * } * * foreach (string str in movedFromAssetPaths) { * DLog.Log("Moved from asset path: " + str); * }*/ List <MovedAsset> moved = new List <MovedAsset>(); for (int kIndex = 0; kIndex < movedAssets.Length; kIndex++) { string movedFromAssetPath = movedFromAssetPaths[kIndex]; try { if (movedFromAssetPath.EndsWith(".mat") || movedFromAssetPath.EndsWith(".prefab")) { string movedFromResourcePath = new AssetFile(movedFromAssetPath).ShowResourcePath(); string movedToResourcePath = new AssetFile(movedAssets[kIndex]).ShowResourcePath(); string movedFromParentFolder = movedFromResourcePath.Substring(0, movedFromResourcePath.LastIndexOf("/")); string movedToParentFolder = movedToResourcePath.Substring(0, movedToResourcePath.LastIndexOf("/")); /*bool isRename = movedFromParentFolder.Equals(movedToParentFolder); * if (isRename) { * DLog.Log("SSARAssetPostprocessor: Renaming detected, skip processing for asset: " + movedFromResourcePath); * continue; * }*/ moved.Add(new MovedAsset( movedFromResourcePath, movedToResourcePath )); if (movedAssets[kIndex].EndsWith(".asset")) { ScriptableObject so = Resources.Load <ScriptableObject>(moved[kIndex].newPath); if (so is SkillFrameConfig) { DLog.Log("Rename skill config, skip detection"); return; } } } } catch (Exception e) { DLog.LogException(new Exception(movedFromAssetPath, e)); } } ContextMenuExtension.MoveOrRenameAsset(moved); var editors = Resources.FindObjectsOfTypeAll <DungeonSpawnConfigEditor>(); foreach (string importedAsset in importedAssets) { /*if (importedAsset.EndsWith(".prefab")) { * GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(importedAsset); * DungeonSpawnConfig dungeonSpawnConfig = prefab.GetComponent<DungeonSpawnConfig>(); * if (!dungeonSpawnConfig) continue; * * string join = string.Join("", dungeonSpawnConfig.config); * dungeonSpawnConfig.configObjectForEditor = new JsonDeserializationOperation(join).Act<DungeonSpawnConfig.Config>(); * /*foreach (DungeonSpawnConfigEditor editor in editors) { * var prefabRoot = PrefabUtility.FindPrefabRoot(((DungeonSpawnConfig)editor.target).gameObject); * var prefabParent = PrefabUtility.GetPrefabParent(prefabRoot); * string prefabPath = AssetDatabase.GetAssetPath(prefabParent); * if (string.IsNullOrEmpty(prefabPath)) { * prefabPath = AssetDatabase.GetAssetPath(prefabRoot); * } * if(!prefabPath.Equals(importedAsset)) continue; * * DLog.Log("PopulateUsingDataReadFromDisk for asset " + importedAsset); * editor.PopulateUsingDataReadFromDisk(dungeonSpawnConfig.config, dungeonSpawnConfig.configObjectForEditor); * }#1# * * foreach (GameObject go in GameObject.FindObjectsOfType<GameObject>()) { * DungeonSpawnConfig otherDsc = go.GetComponent<DungeonSpawnConfig>(); * if (!otherDsc) continue; * var prefabRoot = PrefabUtility.FindPrefabRoot(otherDsc.gameObject); * var prefabParent = PrefabUtility.GetPrefabParent(prefabRoot); * string prefabPath = AssetDatabase.GetAssetPath(prefabParent); * if (string.IsNullOrEmpty(prefabPath)) { * prefabPath = AssetDatabase.GetAssetPath(prefabRoot); * } * if(!prefabPath.Equals(importedAsset)) continue; * * // DLog.Log("PopulateUsingDataReadFromDisk for asset " + importedAsset); * // otherDsc.PopulateUsingDataReadFromDisk(dungeonSpawnConfig.config, dungeonSpawnConfig.configObjectForEditor); * otherDsc.config = dungeonSpawnConfig.config; * otherDsc.configObjectForEditor = dungeonSpawnConfig.configObjectForEditor; * } * }*/ } }
public void OnGUI() { using (new EditorHelper.Horizontal()) { using (new EditorHelper.Vertical()) { using (new EditorHelper.Horizontal()) { float labelWidth = EditorGUIUtility.labelWidth; float fieldWidth = EditorGUIUtility.fieldWidth; int oldIndex = Config.characterIds.IndexOf(monsterId); if (oldIndex == -1) { oldIndex = 0; } GUI.SetNextControlName(challenge.GetHashCode().ToString()); EditorGUIUtility.fieldWidth = 0; EditorGUILayout.LabelField("Monster id", GUILayout.ExpandWidth(false), GUILayout.Width(labelWidth)); GUIStyle gs = new GUIStyle(EditorStyles.popup); string charIdLabel = Config.characterIdsLabels[oldIndex]; if (GUILayout.Button(charIdLabel.Substring(charIdLabel.LastIndexOf('/') + 1, charIdLabel.Length - charIdLabel.LastIndexOf('/') - 1), gs)) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < Config.characterIds.Count; i++) { string mId = Config.characterIds[i]; string label = Config.characterIdsLabels[i]; menu.AddItem( new GUIContent(label), mId.Equals(monsterId), data => { monsterId = (string)data; // DLog.Log(this.GetHashCode() + " monster id " + monsterId); isMonsterIdJustSet = true; // DLog.Log(monsterId); }, mId ); } menu.ShowAsContext(); GUI.changed = false; } if (isMonsterIdJustSet) { isMonsterIdJustSet = false; GUI.changed = true; } EditorGUIUtility.labelWidth = 40; EditorGUIUtility.fieldWidth = 20; EditorGUI.indentLevel -= 2; GUI.SetNextControlName(challenge.GetHashCode().ToString() + 8); monsterLevel = EditorGUILayout.IntField("Level", monsterLevel, GUILayout.ExpandWidth(false)); EditorGUIUtility.labelWidth = labelWidth; EditorGUIUtility.fieldWidth = fieldWidth; EditorGUI.indentLevel += 2; } Direction oldFacingDirection = ShowFacingDirection(); Direction newFacingDirection = (Direction)EditorGUILayout.EnumPopup("Facing direction", oldFacingDirection); facingDirection = newFacingDirection.ToString(); GUI.SetNextControlName(challenge.GetHashCode().ToString() + 9); string newSkillPool = EditorGUILayout.TextField("Spawn skill levels", skillPool); try { ParseSkillLevelPool(newSkillPool); skillPool = newSkillPool; } catch (Exception e) { DLog.LogException(e); } GUI.SetNextControlName(challenge.GetHashCode().ToString() + 1); spawnCount = EditorGUILayout.IntField("Spawn count", spawnCount); using (new EditorHelper.Horizontal()) { GUI.SetNextControlName(challenge.GetHashCode().ToString() + 2); EditorGUILayout.LabelField("Spawn location", GUILayout.Width(EditorGUIUtility.labelWidth), GUILayout.ExpandWidth(false)); float originalFieldWidth = EditorGUIUtility.fieldWidth; float originalLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.fieldWidth = 60; EditorGUIUtility.labelWidth = 20; EditorGUI.indentLevel -= 2; // GUILayout.Space(10); GUI.SetNextControlName(challenge.GetHashCode().ToString() + 3); float newX = EditorGUILayout.FloatField("X", relativePosition.x, GUILayout.ExpandWidth(false)); GUILayout.Space(10); GUI.SetNextControlName(challenge.GetHashCode().ToString() + 4); float newY = EditorGUILayout.FloatField("Y", relativePosition.y, GUILayout.ExpandWidth(false)); GUILayout.Space(10); GUI.SetNextControlName(challenge.GetHashCode().ToString() + 9); float newZ = EditorGUILayout.FloatField("Z", relativePosition.z, GUILayout.ExpandWidth(false)); relativePosition = new Vector3(newX, newY, newZ); EditorGUIUtility.fieldWidth = originalFieldWidth; EditorGUIUtility.labelWidth = originalLabelWidth; EditorGUI.indentLevel += 2; } GUI.SetNextControlName(challenge.GetHashCode().ToString() + 5); xAxisAmplitude = EditorGUILayout.FloatField("X axis amplitude", xAxisAmplitude); GUI.SetNextControlName(challenge.GetHashCode().ToString() + 6); xAxisDensity = EditorGUILayout.IntField("X axis density", xAxisDensity); GUI.SetNextControlName(challenge.GetHashCode().ToString() + 7); spawnInterval = EditorGUILayout.FloatField("Spawn interval", spawnInterval); /*if (!Config.showSpawnerMode || !challenge.IsSpawner()) * { * }*/ DrawTrackers(trackers, ref foldTracker); DrawActions(); EditorWindow inspectorWindow = null; foreach (EditorWindow editorWindow in Resources.FindObjectsOfTypeAll <EditorWindow>()) { if (editorWindow.title.Contains("Inspector")) { inspectorWindow = editorWindow; } } if (GUI.GetNameOfFocusedControl().Contains(challenge.GetHashCode().ToString()) && EditorWindow.mouseOverWindow == inspectorWindow) { if (selectedObject != challenge) { SceneView.lastActiveSceneView.Focus(); inspectorWindow.Focus(); } selectedObject = challenge; } } DrawIconOfCharacterOfSpawner(); } }