private static CCommand ResolveCommand(Type type)
        {
            CCommandAttribute cmdAttr = GetCustomAttribute <CCommandAttribute>(type);

            if (cmdAttr != null)
            {
                string commandName = cmdAttr.Name;
                if (!IsCorrectPlatform(cmdAttr.Flags))
                {
                    Debug.LogWarning("Skipping command: " + commandName);
                    return(null);
                }

                CCommand command = ClassUtils.CreateInstance <CCommand>(type);
                if (command != null)
                {
                    command.Name        = commandName;
                    command.Description = cmdAttr.Description;
                    if (cmdAttr.Values != null)
                    {
                        command.Values = cmdAttr.Values.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    }
                    command.Flags |= cmdAttr.Flags;
                    ResolveOptions(command);

                    return(command);
                }
                else
                {
                    Log.e("Unable to register command: name={0} type={1}", commandName, type);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        private static PlatformImpl CreateImpl()
        {
            try
            {
                if (Application.isEditor)
                {
                    Type type = ClassUtils.TypeForName(EditorPlatformType);
                    if (type != null)
                    {
                        return(ClassUtils.CreateInstance <PlatformImpl>(type));
                    }
                    else
                    {
                        Debug.LogError("Can't find " + EditorPlatformType + " type");
                    }
                }

                return(new PlatformDefault());
            }
            catch (MissingMethodException) // FIXME: I don't like this
            {
                // unit test running
                Type type = ClassUtils.TypeForName("LunarPluginInternal.TestingPlatform");
                return(ClassUtils.CreateInstance <PlatformImpl>(type));
            }
        }