Example #1
0
    void OnEnable()
    {
        specifics = target as PlatformSpecifics;
        specifics.Init();

        //find texture references
        string path = null;
        int    index;

        foreach (string assetPath in AssetDatabase.GetAllAssetPaths())
        {
            index = assetPath.IndexOf("MultiPlatformToolSuite");
            if (index >= 0)
            {
                path = assetPath.Substring(0, index);
                break;
            }
        }
        string editorPath = path + "MultiPlatformToolSuite" + Path.DirectorySeparatorChar + "Editor" + Path.DirectorySeparatorChar;

        path = editorPath + "Textures" + Path.DirectorySeparatorChar;

        addTextureUp      = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "editorAddButtonUp.tga", typeof(Texture2D));
        addTextureDown    = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "editorAddButtonDown.tga", typeof(Texture2D));
        removeTextureUp   = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "editorRemoveButtonUp.tga", typeof(Texture2D));
        removeTextureDown = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "editorRemoveButtonDown.tga", typeof(Texture2D));
        moveItemAboveUp   = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "moveItemAboveUp.tga", typeof(Texture2D));
        moveItemAboveDown = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "moveItemAboveDown.tga", typeof(Texture2D));
        moveItemBelowUp   = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "moveItemBelowUp.tga", typeof(Texture2D));
        moveItemBelowDown = (Texture2D)AssetDatabase.LoadAssetAtPath(path + "moveItemBelowDown.tga", typeof(Texture2D));

        addButtonStyle = new GUIStyle();
        addButtonStyle.normal.background = addTextureUp;
        addButtonStyle.active.background = addTextureDown;
        addButtonStyle.fixedWidth        = addTextureUp.width;
        addButtonStyle.fixedHeight       = addTextureUp.height;
        addButtonStyle.margin            = new RectOffset(4, 4, 4, 4);

        removeButtonStyle = new GUIStyle(addButtonStyle);         //Inherit margin and fixedWidth/Height from addButtonStyle
        removeButtonStyle.normal.background = removeTextureUp;
        removeButtonStyle.active.background = removeTextureDown;

        moveItemAboveStyle = new GUIStyle(addButtonStyle);         //Inherit margin and fixedWidth/Height from addButtonStyle
        moveItemAboveStyle.normal.background = moveItemAboveUp;
        moveItemAboveStyle.active.background = moveItemAboveDown;

        moveItemBelowStyle = new GUIStyle(addButtonStyle);         //Inherit margin and fixedWidth/Height from addButtonStyle
        moveItemBelowStyle.normal.background = moveItemBelowUp;
        moveItemBelowStyle.active.background = moveItemBelowDown;

        showRestrictPlatforms           = (specifics.restrictPlatform != null && specifics.restrictPlatform.Length > 0);
        showMaterials                   = (specifics.materialPerPlatform != null && specifics.materialPerPlatform.Length > 0);
        showLocalScalePerPlatform       = (specifics.localScalePerPlatform != null && specifics.localScalePerPlatform.Length > 0);
        showLocalScalePerAspectRatio    = (specifics.localScalePerAspectRatio != null && specifics.localScalePerAspectRatio.Length > 0);
        showLocalPositionPerPlatform    = (specifics.localPositionPerPlatform != null && specifics.localPositionPerPlatform.Length > 0);
        showLocalPositionPerAspectRatio = (specifics.localPositionPerAspectRatio != null && specifics.localPositionPerAspectRatio.Length > 0);
        showFonts        = (specifics.fontPerPlatform != null && specifics.fontPerPlatform.Length > 0);
        showTextMeshText = (specifics.textMeshTextPerPlatform != null && specifics.textMeshTextPerPlatform.Length > 0);
    }
    //Apply the changes specified in the PlatformSpecifics instance
    static void ApplyPlatformSpecifics(PlatformSpecifics[] specifics, Platform platform, bool stripMaterials)
    {
        //For every platform
        foreach (PlatformSpecifics instance in specifics) {
            //Apply the specific changes
            instance.ApplySpecifics (platform);

            //Once we've applied, lets remove referenced materials to make sure we don't include unnecessary materials on a build
            if (stripMaterials && instance != null)
                instance.materialPerPlatform = null;
        }
    }