CreatePropertyDrawer() private static method

private static CreatePropertyDrawer ( Type klass, string argsText ) : MaterialPropertyDrawer
klass System.Type
argsText string
return MaterialPropertyDrawer
        private static MaterialPropertyDrawer GetShaderPropertyDrawer(string attrib, out bool isDecorator)
        {
            isDecorator = false;
            string str      = attrib;
            string argsText = string.Empty;
            Match  match    = Regex.Match(attrib, "(\\w+)\\s*\\((.*)\\)");

            if (match.Success)
            {
                str      = match.Groups[1].Value;
                argsText = match.Groups[2].Value.Trim();
            }
            foreach (System.Type klass in EditorAssemblies.SubclassesOf(typeof(MaterialPropertyDrawer)))
            {
                if (!(klass.Name == str))
                {
                    if (!(klass.Name == str + "Drawer"))
                    {
                        if (!(klass.Name == "Material" + str + "Drawer"))
                        {
                            if (!(klass.Name == str + "Decorator"))
                            {
                                if (!(klass.Name == "Material" + str + "Decorator"))
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }
                try
                {
                    isDecorator = klass.Name.EndsWith("Decorator");
                    return(MaterialPropertyHandler.CreatePropertyDrawer(klass, argsText));
                }
                catch (Exception ex)
                {
                    Debug.LogWarningFormat("Failed to create material drawer {0} with arguments '{1}'", new object[2]
                    {
                        (object)str,
                        (object)argsText
                    });
                    return((MaterialPropertyDrawer)null);
                }
            }
            return((MaterialPropertyDrawer)null);
        }
示例#2
0
        private static MaterialPropertyDrawer GetShaderPropertyDrawer(string attrib, out bool isDecorator)
        {
            isDecorator = false;
            string text  = attrib;
            string text2 = string.Empty;
            Match  match = Regex.Match(attrib, "(\\w+)\\s*\\((.*)\\)");

            if (match.Success)
            {
                text  = match.Groups[1].Value;
                text2 = match.Groups[2].Value.Trim();
            }
            foreach (Type current in EditorAssemblies.SubclassesOf(typeof(MaterialPropertyDrawer)))
            {
                if (!(current.Name == text) && !(current.Name == text + "Drawer") && !(current.Name == "Material" + text + "Drawer") && !(current.Name == text + "Decorator"))
                {
                    if (!(current.Name == "Material" + text + "Decorator"))
                    {
                        continue;
                    }
                }
                try
                {
                    isDecorator = current.Name.EndsWith("Decorator");
                    MaterialPropertyDrawer result = MaterialPropertyHandler.CreatePropertyDrawer(current, text2);
                    return(result);
                }
                catch (Exception)
                {
                    Debug.LogWarningFormat("Failed to create material drawer {0} with arguments '{1}'", new object[]
                    {
                        text,
                        text2
                    });
                    MaterialPropertyDrawer result = null;
                    return(result);
                }
            }
            return(null);
        }