Search Unity

Question set_position is null for Transform.position with IL2CPP

Discussion in 'Scripting' started by Skullptr, Jan 8, 2023.

  1. Skullptr

    Skullptr

    Joined:
    Aug 28, 2014
    Posts:
    2
    I noticed that set_position delegate (which I get as Action<Vector3> from transform.position) is null when I build *.apk using IL2CPP. With Mono it works correct. How I get the delegate:
    Code (CSharp):
    1.     public static Delegate GetSetDelegateOnProperty<T>(object target, Type targetType, string propertyName)
    2.     {
    3.         PropertyInfo propertyInfo = targetType.GetProperty(propertyName);
    4.  
    5.         if (propertyInfo != null) {
    6.             MethodInfo set = propertyInfo.GetSetMethod();
    7.  
    8.             if (set != null)
    9.                 return Delegate.CreateDelegate(typeof(T), target, set);
    10.         }
    11.  
    12.         return null;
    13.     }
    This is done on purpose or am I overlooking something?
     
    Last edited: Jan 8, 2023
  2. Skullptr

    Skullptr

    Joined:
    Aug 28, 2014
    Posts:
    2
    seems like this is the limitation for IL2CPP. I ended up with implementing get (bridge for Transform). Ugly, but no other choice