Search Unity

Question What's the proper way to handle namespace and obsolete method changes on custom package.

Discussion in 'Scripting' started by chino01, Feb 10, 2021.

  1. chino01

    chino01

    Joined:
    Jul 19, 2014
    Posts:
    13
    Hello everyone!

    I'm developing an in-house module/custom package used by our company. We established some code base but we want to change our namespaces to a completely different one on some modules. There're also some changes on methods and parameters, some methods will be obsolete now.

    This module is used in-house on several projects. I know IDE's can help for finding and changing those easily but I want to use a similar approach to Unity's APIUpdater to be more developer/designer friendly. But I couldn't achieve the automatic renaming of existed namespaces. I understand the apiUpdater is used internally on Unity's packages with success. Should I use another approach or am I missing something completely? Here's my usage code:

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.Scripting.APIUpdating;
    4.  
    5. namespace Company.Namespace
    6. {
    7.     [MovedFrom("Company.OldNameSpace")]
    8.     public class CompanyModuleClass
    9.     {
    10.         public void MethodName(int param1,int param2)
    11.         {
    12.             //Some implementation
    13.         }
    14.  
    15.         [Obsolete("Use MehodName (UnityUpgradable) instead.",true)]
    16.         public void OldMethodName(int param1,int param2)
    17.         {
    18.             //Some implementation
    19.         }
    20.  
    21.     }
    22. }