Skip to content

[Documentation] Signals need Preserve attribute when used with aggressive code stripping #22

Closed
@robotink

Description

@robotink

Fantastic project, thankyou!

Quick note to add to the docs:
When using Signals for mobile and/or using agressive code stripping, Signals will be removed from builds because they aren't statically referenced/linked. You'll want to add a Preserve attribute like this:

using Supyrb;
using UnityEngine.Scripting;

namespace MyNameSpace
{
    [Preserve] //important - must use this attribute if using aggressive stripping on mobile, otherwise this signal won't be found and will throw an error
    public class Signal_MySignal : Signal<bool>
    {
        // Override invoke to make sure that the derived signal class shows up in the stacktrace
        protected override void Invoke(int index)
        {
            base.Invoke(index);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions