public static bool SelectionHaveContainers() { foreach (var text in Selection.GetFiltered <TextAsset>(SelectionMode.DeepAssets)) { if (ContainerRef.FromTextAsset(text, false).IsValid) { return(true); } } return(false); }
public override void OnGUI(Rect rect) { var pos = new Rect(new Vector2(), GetWindowSize()); pos = pos.Expand(-2f); // 2-pixel margins var updatedContainer = _view.Draw(pos); if (updatedContainer != null && _asset != null) { ContainerAssetUtils.WriteToTextAsset(updatedContainer, _asset); var container = ContainerRef.FromTextAsset(_asset).Container as BinaryContainer; _view = new ContainerEditorView(new ContainerEditorInfo(container), _asset); } }
public static void UpdateSerializers() { int totalCount = 0; int changedCount = 0; int errorsCount = 0; TextAsset lastUpdated = null; foreach (var text in Selection.GetFiltered <TextAsset>(SelectionMode.DeepAssets)) { try { var containerRef = ContainerRef.FromTextAsset(text, false); if (!containerRef.IsValid) { continue; } if (containerRef.UpdateSerializers()) { changedCount++; } totalCount++; lastUpdated = text; } catch (Exception e) { Debug.LogError($"Error updating serializers for {text.name}:\n{e.GetType().PrettyName()}: {e.Message}\n\n{e.StackTrace}", text); errorsCount++; } } if (errorsCount > 0) { Debug.LogWarning($"(Errors) Serializers updated for {totalCount} containers. {changedCount} changed. {errorsCount} errors (cannot update)\n", totalCount == 1 ? lastUpdated : null); } else { Debug.Log($"Serializers updated for {totalCount} containers. {changedCount} changed.\n", totalCount == 1 ? lastUpdated : null); } }
public ContainerEditorInfo(TextAsset textAsset, bool verbose = false) { var containerRef = ContainerRef.FromTextAsset(textAsset, verbose); _container = containerRef.Container as BinaryContainer; }
public static bool SelectionIsContainer() { var text = Selection.activeObject as TextAsset; return(ContainerRef.FromTextAsset(text, false).IsValid); }