internal static void DestroyWorld() { if (!InitStarted) { return; } InitStarted = false; Destroyed = true; Asr.IsFalse(__GlobalsCounter.HasAnyValue()); }
public void Release(ref T element) { #if !M_DISABLE_POOLING Asr.IsFalse(_stack.Count > 0 && ReferenceEquals(_stack.Peek(), element), "Internal error. Trying to release object that is already released to pool. "); _reset.Invoke(element); _stack.Push(element); #endif element = null; }
public static bool IgnoredPaths(string path, out string str) { var conf = Globals <Config> .Value; foreach (var substr in conf.IgnorePathContains) { Asr.IsNotNull(path); Asr.IsNotNull(substr); if (!path.Contains(substr)) { continue; } str = substr; return(true); } str = default; return(false); }
public static bool TryFindSelf(out Style value) { const string typeName = nameof(CleanerStyleAsset); var guids = AssetDatabase.FindAssets($"t:{typeName}"); if (!guids.Any()) { AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } Asr.IsTrue(guids.Length > 0, $"No '{typeName}' assets found"); var res = guids.Select(AssetDatabase.GUIDToAssetPath).Select(t => (CleanerStyleAsset)AssetDatabase.LoadAssetAtPath(t, typeof(CleanerStyleAsset))).FirstOrDefault(); if (res == null) { value = default; return(false); } value = EditorGUIUtility.isProSkin ? res.Pro : res.Personal; return(value != null); }
public static void Init(SearchArg arg, Object target, Scene scene = default) { Asr.IsNotNull(target, "Asset you're trying to search is corrupted"); arg.Target = target; arg.FilePath = AssetDatabase.GetAssetPath(arg.Target); if (!scene.IsValid()) { Upd(arg); arg.Main = AssetDatabase.LoadMainAssetAtPath(arg.FilePath); if (AssetDatabase.IsSubAsset(arg.Target)) { } else { switch (target) { case SceneAsset _: // todo support cross-scene references? // nested = all assets break; default: // AssetDatabase.IsMainAssetAtPathLoaded() var subAssets = AssetDatabase.LoadAllAssetsAtPath(arg.FilePath).Where(Predicate).ToArray(); arg.SubAssets = subAssets.Length == 0 ? default(Option <Object[]>) : subAssets; bool Predicate(Object s) { if (!s) { return(false); } return(s.GetInstanceID() != arg.Target.GetInstanceID()); } break; } } } else { switch (arg.Target) { case GameObject gg: arg.Main = gg; arg.Scene = scene; arg.SubAssets = gg.GetComponents <Component>().OfType <Object>().ToArray(); break; case Component component: { // treat like subAsset arg.Main = component.gameObject; arg.Scene = scene; break; } default: // project asset such as Material arg.Main = arg.Target; arg.Scene = scene; break; } } }
public static T GetSingle <T>(this EcsFilter <T> f) where T : class { Asr.AreEqual(f.GetEntitiesCount(), 1); return(f.Get1[0]); }