We found that in our game code, the main program wrote a lot of code similar to this:
Public static t Createobject <t> (Out int objectid) where T: New () // method name
Public class csingleton <t> where T: New () // Singleton class
Public t getcontrol <t> (string Uri, transform findtrans = NULL, bool islog = true) where T: unityengine. Object // search for the UI control based on URL and type
Public t findcontrol <t> (string name) where T: Component
Public void OpenWindow <t> (Params object [] ARGs) where T: cuibase
Public void callui <t> (Action <t, object []> callback, Params object [] ARGs) where T: cuibase
Public void loadtab <t> (string tabpath) where T: cbaseinfo, new () // load the tab table
----- Specific usage -----
Definition: Public t getinfo <t> (string ID) where T: cbaseinfo
Use: actorinfo = cgamesettings. instance. getinfo <actorinfo> (actorid );
Explanation: [T getinfo (string ID)] When an ID is input, a class is returned. [where T: cbaseinfo] indicates that the type of this class must inherit cbaseinfo.
Of course, some plug-ins in the project are similar:
Fingergestures
Public abstract class continuousgesturerecognizer <t>: gesturerecognizerts <t> where T: continuousgesture, new ()
Public static t createasset <t> () where T: scriptableobject
Public abstract class fingereventdetector <t>: fingereventdetector where T: fingerevent, new ()
Ngui
Static public T [] findactive <t> () where T: Component
Static public t addchild <t> (gameobject parent, bool UNDO) where T: Component
Static public t begin <t> (gameobject go, float duration) where T: uitweener
Tk2d
Public static t loadresourcebyname <t> (string guid) where T: unityengine. Object
Public static t addcomponent <t> (gameobject go, tk2dspritecollectiondata spritecollection, string spritename) where T: tk2dbasesprite