
This package provides structured success and error handling for Unity projects, enabling efficient debugging and flexible result management for any data type.Search Result Pro takes Unity data handling to the next level, providing developers with advanced, flexible error-handling options. Designed with professional projects in mind, it delivers more comprehensive control over data retrieval, modifications, and comparison.Search Result Pro builds upon the simplicity of the Lite version, adding expanded functionality for developers seeking a powerful, adaptable solution.🌐 Website: https://doshagyasinggowardun.weebly.com💡 Support: https://discord.gg/BkgHX5VnKC🌱 Lite Version: https://u3d.as/3q4cKey FeaturesUse Search Result Pro to manage and track errors in complex workflows. Customizable error messages and error-state tracking empower you to isolate issues faster.Modify data dynamically with TryModify(), giving you an easy way to update values when error-free or to debug when errors are flagged.Advanced Error ControlCompare error states effortlessly with custom operators (== and !=) to check for successful or faulty data retrieval without additional checks.Flexible ModificationsIntuitive Boolean ComparisonAccess ToString() for detailed data and error output, streamlining the debug process and error message handling, even for complex data types.Enhanced Debugging ToolsKey Use Cases in Unity Projects1. Safe Data AccessLists and Arrays: The SafeGet extension methods for lists and arrays help retrieve elements without worrying about null references, out-of-bounds errors, or runtime crashes. For example:var myList = new List { 1, 2, 3 };var result = myList.SafeGet(5);if (result.isError) Debug.LogError(result.errorMessage);else Debug.Log(result.result);This is especially useful when working with dynamically sized collections, such as inventories, object pools, or runtime-generated datasets.2. Error Messaging with ContextThe use of [CallerMemberName] and [CallerLineNumber] attributes in SafeGet methods allows developers to quickly identify where an error occurred in the code. This makes debugging faster and more intuitive.Example: “Index is outside bounds of array at MyMethod at line 42.”3. GameObject ModificationsThe SafeModify method provides a structured way to modify GameObjects while handling potential exceptions gracefully. This can be used for tasks such as:Adding or removing components.Updating properties (e.g., transform.position, Renderer.material).Custom logic based on runtime checks.Example:GameObject myObject = GameObject.Find("Player");myObject.SafeModify(obj =>{ obj.transform.position = new Vector3(0, 1, 0);}, error => Debug.LogError(error));4. Preventing Common Errors in UnityNull Reference Exceptions: These extensions ensure that null references are caught and handled before they cause crashes.Index Out-of-Bounds: Improves safety when accessing indices, reducing runtime errors caused by invalid inputs.Runtime Exception Handling: Provides a unified approach to catching exceptions across different object types, ensuring smoother gameplay and debugging.5. Customization and ExtendabilityBy providing a generic structure (SearchResult), this framework allows developers to easily extend functionality to other data types, like custom structs or objects.For instance, a custom extension method could be created for retrieving specific components from a list of GameObjects:public static SearchResult SafeGetComponent(this GameObject obj) where T : Component{ if (obj == null) return SearchResult.Error("GameObject is null"); T component = obj.GetComponent(); return component != null ? SearchResult.Success(component) : SearchResult.Error($"Component {typeof(T)} not found on GameObject");}6. Collaborative Development and Modular CodeEnables safer code when multiple developers are working on a project. The clear separation of error handling (e.g., using onError callbacks) and functional logic (e.g., onSuccess) helps streamline debugging and maintenance.Example:myGameObject.SafeModify(obj =>{ obj.AddComponent();}, error => Debug.LogError($"Failed to modify GameObject: {error}"));7. Error Logging for QA and Bug TrackingWith precise error messages and contextual information, QA testers can pinpoint issues and provide detailed reports. Developers can also integrate these error messages with bug tracking tools.Benefits for Unity DevelopersReduced Debugging Time: Eliminates the need to manually write boilerplate error checks for common operations.Improved Stability: Prevents crashes caused by common mistakes like accessing null objects or out-of-range indices.Enhanced Collaboration: Clear error reporting ensures team members can quickly identify and resolve issues.Code Reusability: The generic approach and extensible design ensure that these utilities can be reused across various projects and scenarios.By integrating these utilities into a Unity project, developers can focus on building features and gameplay mechanics rather than worrying about runtime stability.Use Case: Safe Inventory Management in a Game (Using PRO version)ScenarioYou are building an inventory system for an RPG game. Players can access their inventory to view items or equip them during gameplay. However, there may be cases where the player tries to access an item that doesn’t exist or the inventory is empty. The SearchResultPro class ensures these operations are handled gracefully without breaking the game flow.Code Example:using UnityEngine;using System.Collections.Generic;using RedstoneinventeGameStudio.Pro.Utilities;public class InventoryManager : MonoBehaviour{ private List inventoryItems; void Awake() { // Add a default check to quickly check results before returning AddDefaultCheck(); } void Start() { TestSafeGet(1); // Null references are also handled // Initialize inventory with some items inventoryItems = new List { "Sword", "Shield", "Potion" }; // Use SafeGet to access an item safely TestSafeGet(1); // Valid index TestSafeGet(-1); // Invalid index TestSafeGet(10); // Out of bounds index } void TestSafeGet(int index) { // Using SafeGet with inline success and error handling inventoryItems.SafeGet(index, onSuccess: item => Debug.Log($"Successfully retrieved item: {item}"), onError: error => Debug.LogError($"Failed to retrieve item: {error}") ); } public void EquipItem(int index) { // Use SafeGet to retrieve an item before equipping SearchResultPro result = inventoryItems.SafeGet(index); if (result) { Debug.Log($"Equipping item: {result.result}"); // Equip logic here... } else { Debug.LogError($"Cannot equip item: {result.errorMessage}"); } } public void AddDefaultCheck() { // Set a default predicate to prevent equipping empty or invalid item names SearchResultPro.SetDefaultCheck(item => !string.IsNullOrEmpty(item)); }}Features Demonstrated:Safe Retrieval:Use SafeGet to avoid runtime errors when accessing inventory items, especially when indices are out of range.Error Handling with Callbacks:Inline onSuccess and onError callbacks provide immediate and readable handling of success or failure scenarios.Custom Default Checks:Ensure retrieved items meet specific criteria by adding a defaultCheck. For example, prevent equipping items with invalid names.Implicit Conversion:Simplifies error checking with implicit conversion (if (result)), making the code cleaner and easier to understand.Pro Extensions:The extended functionality adds safety and clarity when working with collections like arrays and lists, reducing potential errors and debugging time.Example Output:List is empty at TestSafeGet at line 17Successfully retrieved item: ShieldFailed to retrieve item: Index is outside bounds of array at TestSafeGet at line 24Failed to retrieve item: Index is outside bounds of array at TestSafeGet at line 25Equipping item: SwordCannot equip item: Index is outside bounds of arrayThis use case highlights how the Pro Version enhances development by providing robust, reusable, and error-resilient data handling tools. It reduces the need for repetitive null checks, making your codebase more efficient and readable.Supported PlatformsDesktopAndroidiOSWebGLMacOSConsolesWhy Choose Search Result Lite & Pro?This asset solves real-world problems faced by Unity developers, making your projects safer, smoother, and easier to manage. The Lite version is perfect for those looking to try safe access methods, while Pro unlocks advanced tools and customization for professional-grade projects.Take the hassle out of debugging and let Search Result Lite & Pro do the heavy lifting for you.Get started with Lite for free or upgrade to Pro to unlock the full potential of your workflow!With ongoing development and user feedback-driven enhancements, Search Result Pro is designed to meet professional-level needs in Unity development. Join our community to share ideas and stay updated on new features!Key Features:Success/Error Encapsulation: Provides structured handling for both success and error states.Data Customization: Supports any data type, allowing flexible usage across projects.Automatic Error Logging: Logs errors on detection, aiding quick debugging.Safe Data Modification: Modifies variables only if there are no errors, preventing unwanted changes.Boolean and String Conversions: Supports implicit conversions for simpler logic and messaging.Operator Overloads: Easy comparison with boolean values for quick checks.Comprehensive Documentation: Includes setup, usage examples, and detailed method explanations.