Esempio n. 1
0
        private static void OnItemCallback(string guid, Rect rect)
        {
            //ignore drawing if ToolboxEditorProject functionalites are not allowed
            if (!ToolboxFolderUtility.ToolboxFoldersAllowed)
            {
                return;
            }

            var path = AssetDatabase.GUIDToAssetPath(guid);

            //try to get icon for this folder
            if (!ToolboxFolderUtility.TryGetFolderData(path, out FolderData data))
            {
                return;
            }

            Texture icon;

            //adjust rect for icon depending on current view and handled texture
            if (rect.width > rect.height)
            {
                icon = data.SmallIcon;

                //determinate exact folder icon rect
                rect = new Rect(rect.xMin, rect.y, Style.folderIconWidthSmall, Style.folderIconHeightSmall);

                rect.x     += Style.padding;
                rect.y     += rect.height * Style.yToHeightRatioSmall;
                rect.width  = Style.iconWidthSmall;
                rect.height = Style.iconHeightSmall;
            }
            else
            {
                icon = data.Icon;

                var offset     = Mathf.Max(rect.height - Style.labelHeight - Style.folderIconHeight, 0);
                var iconHeight = rect.height - Style.labelHeight - offset;

                //determinate exact folder icon rect
                rect = new Rect(rect.x, rect.yMin + offset / 2 + Style.spacing, rect.width, iconHeight);

                //calculate multipliers
                var widthRatio  = iconHeight / Style.folderIconWidth;
                var heightRatio = iconHeight / Style.folderIconHeight;

                //set final rect
                rect.x     += rect.width * Style.xToWidthRatio;
                rect.y     += rect.height * Style.yToHeightRatio;
                rect.width  = Style.iconWidth * widthRatio;
                rect.height = Style.iconHeight * heightRatio;
            }

            if (icon == null)
            {
                return;
            }

            GUI.DrawTexture(rect, icon, ScaleMode.ScaleToFit, true);
        }
Esempio n. 2
0
        internal static void InitializeSettings(string assetGuid)
        {
            settingsGuid = assetGuid;
            settingsPath = AssetDatabase.GUIDToAssetPath(assetGuid);
            //try to get proper settings asset from provided guid
            var settings = AssetDatabase.LoadAssetAtPath <ToolboxEditorSettings>(settingsPath);

            if (settings == null)
            {
                ToolboxEditorLog.KitInitializationWarning(settingsType);
                return;
            }

            Settings = settings;

            //initialize core functionalities
            ToolboxDrawerUtility.InitializeDrawers(Settings);
            ToolboxFolderUtility.InitializeProject(Settings);
        }
Esempio n. 3
0
        internal static void InitializeSettings(string assetGuid)
        {
            const string warningMessage = settingsType +
                                          " asset file not found. Cannot initialize Toolbox core functionalities. " +
                                          "You can create new settings file using CreateAsset menu -> Create -> Toolbox Editor -> Settings.";

            settingsGuid = assetGuid;
            settingsPath = AssetDatabase.GUIDToAssetPath(assetGuid);
            //try to get proper settings asset from provided guid
            var settings = AssetDatabase.LoadAssetAtPath <ToolboxEditorSettings>(settingsPath);

            if (settings == null)
            {
                Debug.LogWarning(warningMessage);
                return;
            }

            Settings = settings;

            //initialize core functionalities
            ToolboxDrawerUtility.InitializeDrawers(Settings);
            ToolboxFolderUtility.InitializeProject(Settings);
        }