コード例 #1
0
        public static string[] GetAllTexturesInPath(string path)
        {
            List <string> files        = new List <string>();
            string        absolutePath = Application.dataPath + "/" + path.Remove(0, 7);

            string [] fileEntries = Directory.GetFiles(absolutePath);
            int       count       = fileEntries.Length;
            int       i           = 0;

            foreach (string fileName in fileEntries)
            {
                string fname     = fileName.Replace('\\', '/');
                int    index     = fname.LastIndexOf('/');
                string localPath = path;
                if (index > 0)
                {
                    localPath += fname.Substring(index);
                }
                VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Discovering Assets in folder...", (float)i / count);
                Texture2D t = AssetDatabase.LoadAssetAtPath <Texture2D>(localPath);
                if (t != null)
                {
                    files.Add(localPath);
                }
                i++;
            }
            VFXToolboxGUIUtility.ClearProgressBar();
            return(files.ToArray());
        }
コード例 #2
0
        internal virtual void OnGUI()
        {
            if (m_bgBrightness < 0.0f)
            {
                ResetBrightness();
            }

            // Focus taken when clicked in viewport
            if (Event.current.type == EventType.MouseDown && m_Rect.Contains(Event.current.mousePosition))
            {
                GUI.FocusControl("");
            }

            if (texture != null && Event.current.type == EventType.Repaint)
            {
                if (m_IsDirtyRenderTarget)
                {
                    UpdateRenderTarget();
                }

                if (m_bNeedRedraw)
                {
                    BlitIntoRenderTarget();
                    m_bNeedRedraw = false;
                }
            }

            GUI.BeginGroup(m_Rect);
            Rect LocalRect = new Rect(Vector2.zero, m_Rect.size);

#if !UNITY_2018_2_OR_NEWER
            GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
#endif
            GUI.DrawTextureWithTexCoords(LocalRect, BackgroundTexture, new Rect(0, 0, m_Rect.width / 64, m_Rect.height / 64));

#if !UNITY_2018_2_OR_NEWER
            //GL.sRGBWrite = false;
#endif
            if (texture != null)
            {
                HandleKeyboardEvents();

#if !UNITY_2018_2_OR_NEWER
                GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
#endif
                DrawCurrentTexture();
#if !UNITY_2018_2_OR_NEWER
                //GL.sRGBWrite = false;
#endif

                if (showGrid)
                {
                    DrawGrid();
                }
                onCanvasGUI?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                GUI.Label(LocalRect, VFXToolboxGUIUtility.Get("No Texture"), EditorStyles.centeredGreyMiniLabel);
            }

#if !UNITY_2018_2_OR_NEWER
            //GL.sRGBWrite = false;
#endif

            GUI.EndGroup();
        }