Ejemplo n.º 1
0
    void LoadAssets(string searchedExtension = ".prefab")
    {
        if (assetList.Count == 0)
        {
            foreach (APTabPlacementData tabData in tabList)
            {
                var filePaths = Directory.GetFiles(tabData.filePath);
                foreach (string filePath in filePaths)
                {
                    var name      = filePath.Remove(0, FolderPath().Length + 1);
                    var localPath = "Assets/" + filePath.Remove(0, FolderPath().Length - folderName.Length);

                    if (name.EndsWith(searchedExtension))
                    {
                        var assetData = new APData(localPath, name, tabData.name);
                        assetList.Add(assetData);

                        string fixedPath = localPath;

                        var prefab = AssetDatabase.LoadAssetAtPath(fixedPath, typeof(GameObject)) as GameObject;
                        assetData.gameObject = prefab;

                        var foundHotKey = EditorPrefs.GetString(APGlobals.SavedHotkeyDisplayName + assetData.name);
                        if (foundHotKey.Length > 0)
                        {
                            foundHotKey       = foundHotKey.Replace(" ", string.Empty);
                            assetData.keyCode = (KeyCode)System.Enum.Parse(typeof(KeyCode), foundHotKey);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    private static GameObject CreateStagedAsset(APData assetData, GameObject stagedContainer)
    {
        var stagedAsset = PrefabUtility.InstantiatePrefab(assetData.gameObject) as GameObject;

        stagedAsset.name                    = "StagedAsset";
        stagedAsset.transform.parent        = stagedContainer.transform;
        stagedAsset.transform.localPosition = Vector3.zero;
        SceneView.RepaintAll();
        return(stagedAsset);
    }
Ejemplo n.º 3
0
    bool ByButtonSelection()
    {
        var selectedAssetNumber = EditorPrefs.GetInt(APGlobals.SelectedAssetNumber);

        if (selectedAssetNumber != APGlobals.HotKeySelectionEnabled)
        {
            selectedAsset = assetList [selectedAssetNumber];
            return(true);
        }
        return(false);
    }
Ejemplo n.º 4
0
	void CreateTabLabel (APData assetData, Rect buttonRect) {
		Rect labelRect = new Rect(buttonRect.x + buttonRect.width * 0.1f, buttonRect.y + buttonRect.height * 0.1f, buttonRect.width * 0.8f, buttonRect.width * 0.2f); 
		
		GUI.DrawTexture (new Rect (labelRect.x,
		                           labelRect.y - labelRect.height * 0.1f, 
		                           labelRect.width,
		                           labelRect.height)
		                 , backgroundAlpha);
		
		var labelStyle = new GUIStyle ();
		labelStyle.fontSize = 14;
		labelStyle.fontStyle = FontStyle.Bold;
		labelStyle.normal.textColor = Color.black;
		GUI.Label (labelRect, assetData.tab, labelStyle);
	}
Ejemplo n.º 5
0
    void ByHotKeySelection()
    {
        int index = 0;

        foreach (APData data in assetList)
        {
            if (getSelectedTab() != null && data.tab == getSelectedTab().name)
            {
                if (data.keyCode == (KeyCode)EditorPrefs.GetInt(APGlobals.SelectedKey))
                {
                    selectedAsset = data;

                    EditorPrefs.SetInt(APGlobals.SelectedAssetNumber, index);
                }
            }

            index++;
        }
    }
Ejemplo n.º 6
0
        private void buttonFolderBrowserImport_Click(object sender, EventArgs e)
        {
            try
            {
                progressBarLoadDataTime.Value = 0;
                if (folderBrowserDialogImport.ShowDialog() == DialogResult.OK)
                {
                    ///// Parse and Import directory.
                    this.RootPath      = folderBrowserDialogImport.SelectedPath;
                    NewFileInfosBuffer = GetFiles(this.RootPath);
                    MessageBox.Show("New FileInfos Buffer count is " + NewFileInfosBuffer.Count);
                    if (checkBoxAutoEverything.Checked == true)
                    {
                        int progressTracker = 0;
                        int total           = NewFileInfosBuffer.Count;

                        foreach (FileInfo x in NewFileInfosBuffer)
                        {
                            int donePct = progressTracker / total * 100;
                            progressBarLoadDataTime.Value = donePct;
                            Image retValStub = APData.ParseFileNameToImageInfo(x.FullName, ADC);
                            if (retValStub != null)
                            {
                                APData.AddImage(retValStub, ADC);
                            }
                            progressTracker++;
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Ejemplo n.º 7
0
    public static Texture2D CreateTextureFromCamera(APData assetData, ref bool hasMadeAnIconRenderAsset)
    {
        string fixedName = assetData.name.Replace('/', '_');

        fixedName = fixedName.Replace('.', '_');

        var textureFilePath = CreateFileDirectory(fixedName);

        var foundScreenShot = FindTakenScreenshot(fixedName, textureFilePath);

        if (foundScreenShot)
        {
            return(foundScreenShot);
        }
        else
        {
            hasMadeAnIconRenderAsset = true;

            var stagedContainer = CreateStage();
            var stagedCamera    = CreateStageCamera(stagedContainer);
            var stagedAsset     = CreateStagedAsset(assetData, stagedContainer);

            CreateStageLightMain(stagedContainer);
            CreateStageLightSub(stagedContainer);
            CreateStageLightSun(stagedContainer);

            FocusStageCameraOnAsset(stagedCamera, stagedAsset, stagedContainer);
            TakeStageScreenshot(textureFilePath, stagedCamera, stagedAsset);

            AssetDatabase.ImportAsset(textureFilePath);

            EditorWindow.DestroyImmediate(stagedAsset);

            return(null);
        }
    }