Beispiel #1
0
        static List <ReactCandidateClass> CollectCandidates()
        {
            ifTemplate              = ReactEditorUtility.LoadTemplate("React_If_Template");
            conditionTemplate       = ReactEditorUtility.LoadTemplate("React_Condition_Template");
            functionTemplate        = ReactEditorUtility.LoadTemplate("React_Function_Template");
            setTemplate             = ReactEditorUtility.LoadTemplate("React_Set_Template");
            staticIfTemplate        = ReactEditorUtility.LoadTemplate("React_Static_If_Template");
            staticConditionTemplate = ReactEditorUtility.LoadTemplate("React_Static_Condition_Template");
            staticFunctionTemplate  = ReactEditorUtility.LoadTemplate("React_Static_Function_Template");
            staticSetTemplate       = ReactEditorUtility.LoadTemplate("React_Static_Set_Template");

            CreateClassesForType(typeof(RemoteSettings));
            CreateClassesForType(typeof(Cursor));
            CreateClassesForType(typeof(Debug));
            CreateClassesForType(typeof(Handheld));
            CreateClassesForType(typeof(Input));
            CreateClassesForType(typeof(ParticleSystem));
            CreateClassesForType(typeof(Application));
            CreateClassesForType(typeof(Physics));
            CreateClassesForType(typeof(PlayerPrefs));

            var commonTypes = new[] {
                typeof(Transform),
                typeof(Light),
                typeof(Renderer),
                typeof(Collider),
                typeof(Collider2D),
                typeof(Physics),
                typeof(Physics2D),
                typeof(Rigidbody),
                typeof(Rigidbody2D),
                typeof(Animator),
                typeof(AudioSource),
                typeof(Camera),
                typeof(Animation),
                typeof(ParticleSystem),
                typeof(TrailRenderer),
                typeof(AudioEchoFilter), typeof(AudioChorusFilter), typeof(AudioReverbFilter),
                typeof(AudioLowPassFilter), typeof(AudioHighPassFilter), typeof(AudioDistortionFilter),
                typeof(HingeJoint), typeof(HingeJoint2D),
                typeof(LineRenderer),
                typeof(SpriteRenderer)
            };

            foreach (var i in commonTypes)
            {
                CreateClassesForType(i);
            }

            foreach (var i in AssetDatabase.FindAssets("t:ReactComponentDatabase"))
            {
                var db = AssetDatabase.LoadAssetAtPath <ReactComponentDatabase>(AssetDatabase.GUIDToAssetPath(i));
                foreach (var ms in db.scripts)
                {
                    var ct = ms.GetClass();
                    if (!ct.IsSubclassOf(typeof(Component)))
                    {
                        continue;
                    }
                    if (ct.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                    {
                        continue;
                    }
                    if (ct.IsValueType)
                    {
                        continue;
                    }
                    if (!ct.IsPublic)
                    {
                        continue;
                    }
                    CreateClassesForType(ct);
                }
            }
            return(candidates);
        }
Beispiel #2
0
        static List <ReactCandidateClass> CollectAllCandidates()
        {
            ifTemplate              = ReactEditorUtility.LoadTemplate("React_If_Template");
            conditionTemplate       = ReactEditorUtility.LoadTemplate("React_Condition_Template");
            functionTemplate        = ReactEditorUtility.LoadTemplate("React_Function_Template");
            setTemplate             = ReactEditorUtility.LoadTemplate("React_Set_Template");
            staticIfTemplate        = ReactEditorUtility.LoadTemplate("React_Static_If_Template");
            staticConditionTemplate = ReactEditorUtility.LoadTemplate("React_Static_Condition_Template");
            staticFunctionTemplate  = ReactEditorUtility.LoadTemplate("React_Static_Function_Template");
            staticSetTemplate       = ReactEditorUtility.LoadTemplate("React_Static_Set_Template");

            CreateClassesForType(typeof(RemoteSettings));
            CreateClassesForType(typeof(Cursor));
            CreateClassesForType(typeof(Debug));
            CreateClassesForType(typeof(Handheld));
            CreateClassesForType(typeof(Input));
            CreateClassesForType(typeof(ParticleSystem));
            CreateClassesForType(typeof(Application));
            CreateClassesForType(typeof(Physics));
            CreateClassesForType(typeof(PlayerPrefs));

            var typeBlacklist = new HashSet <string>(new[] { "NetworkScenePostProcess" });
            var assBlacklist  = new[] { "UnityEditor", "HoloLens" };

            foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
            {
                var skip = false;
                foreach (var ab in assBlacklist)
                {
                    if (ass.IsDynamic || ass.Location.Contains(ab))
                    {
                        skip = true;
                    }
                }
                if (skip)
                {
                    continue;
                }
                foreach (var ct in ass.GetTypes())
                {
                    if (!ct.IsSubclassOf(typeof(Component)))
                    {
                        continue;
                    }
                    if (ct.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                    {
                        continue;
                    }
                    if (ct.IsValueType)
                    {
                        continue;
                    }
                    if (!ct.IsPublic)
                    {
                        continue;
                    }
                    if (typeBlacklist.Contains(ct.Name))
                    {
                        continue;
                    }
                    CreateClassesForType(ct);
                }
            }
            return(candidates);
        }