docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method Destroy

    Destroy(Object, bool)

    Calls the proper Destroy method on an object based on if application is playing.

    Declaration
    public static void Destroy(Object obj, bool withUndo = false)
    Parameters
    Type Name Description
    Object obj

    Object to be destroyed.

    bool withUndo

    Whether to record and undo operation for the destroy action.

    Remarks

    In Play mode or when running your built application, this function calls Destroy.

    In the Editor, outside of Play mode, this function calls DestroyImmediate.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)