Exemplo n.º 1
0
 public static void Window(int windowID)
 {
     scrollPosition3 = GUILayout.BeginScrollView(scrollPosition3, style: "SelectedButtonDropdown");
     if (AssetUtilities.GetSkins().Count == 0)
     {
         GUILayout.Label("put gui skins in /Unturned/Unturned_Data/GUISkins/");
     }
     foreach (string skin in AssetUtilities.GetSkins())
     {
         string s = skin;
         if (s == G.Settings.MiscOptions.UISkin)
         {
             s = $"<b>{s}</b>";
         }
         if (GUILayout.Button(s))
         {
             AssetUtilities.LoadGUISkinFromName(skin);
         }
     }
     GUILayout.EndScrollView();
     GUILayout.Space(2);
     if (GUILayout.Button("Load Default GUI"))
     {
         G.Settings.MiscOptions.UISkin = "";
         AssetUtilities.Skin           = AssetUtilities.VanillaSkin;
     }
     if (GUILayout.Button("Close Window"))
     {
         GUISkinMenuOpen = !GUISkinMenuOpen;
     }
     GUI.DragWindow();
 }
            private void OnListTitlebarGUI()
            {
                if (this.PrettyPath != null)
                {
                    GUILayout.Label(this.PrettyPath, SirenixGUIStyles.RightAlignedGreyMiniLabel);
                    SirenixEditorGUI.VerticalLineSeparator();
                }

                if (this.IsPopulated)
                {
                    GUILayout.Label(this.List.SmartValue.Count + " / " + this.toggleableAssets.Count, EditorStyles.centeredGreyMiniLabel);
                }
                else
                {
                    GUILayout.Label("Scanning " + this.CurrentSearchingIndex + " / " + this.NumberOfResultsToSearch, SirenixGUIStyles.RightAlignedGreyMiniLabel);
                }
                bool disableGUI = !this.IsPopulated;

                if (disableGUI)
                {
                    GUIHelper.PushGUIEnabled(false);
                }

                if (SirenixEditorGUI.ToolbarButton(EditorIcons.Refresh) && this.IsPopulated)
                {
                    this.Rescan();
                }

                if (AssetUtilities.CanCreateNewAsset <TElement>())
                {
                    if (SirenixEditorGUI.ToolbarButton(EditorIcons.Plus) && this.IsPopulated)
                    {
                        string path = this.PrettyPath;
                        if (path == null)
                        {
                            var lastAsset = this.List.SmartValue.Count > 0 ? this.List.SmartValue[this.List.SmartValue.Count - 1] as TElement : null;
                            if (lastAsset == null)
                            {
                                var lastToggleable = this.toggleableAssets.LastOrDefault();
                                if (lastToggleable != null)
                                {
                                    lastAsset = lastToggleable.Object;
                                }
                            }
                            if (lastAsset != null)
                            {
                                path = AssetUtilities.GetAssetLocation(lastAsset);
                            }
                        }
                        AssetUtilities.CreateNewAsset <TElement>(path, null);
                        this.Rescan();
                    }
                }

                if (disableGUI)
                {
                    GUIHelper.PopGUIEnabled();
                }
            }
Exemplo n.º 3
0
        public void Setup(OdinMenuTree tree)
        {
            var assets = AssetUtilities.GetAllAssetsOfType <ScriptableObject>();

            foreach (var asset in assets)
            {
                var type = asset.GetType();

                // TODO: Remove namespace from path
                if (type.GetCustomAttribute <ShowInMenuAttribute>() != null)
                {
                    tree.AddObjectAtPath($"{Path}{type}/{asset.name}", asset);
                }
            }
        }
Exemplo n.º 4
0
        void OnGUI()
        {
            if (SettingsTypes.Count == 0)
            {
                EditorGUILayout.LabelField("No Mod Settings Types have been found");
                return;
            }
            EditorGUILayout.LabelField("Select the Mod Settings File to Create:");
            index = EditorGUILayout.Popup(index, settingsNames);

            if (GUILayout.Button("Create"))
            {
                Close();
                AssetUtilities.CreateScriptableObject(SettingsTypes[index]);
            }
        }
Exemplo n.º 5
0
            private IEnumerator PupulateListRotine()
            {
                while (true)
                {
                    if (this.IsPopulated)
                    {
                        yield return(null);

                        continue;
                    }

                    HashSet <UnityEngine.Object> seenObjects = new HashSet <UnityEngine.Object>();
                    int[] layers = this.LayerNames != null?this.LayerNames.Select(l => LayerMask.NameToLayer(l)).ToArray() : null;

                    this.AvailableAsset.Clear();

                    IEnumerable <AssetUtilities.AssetSearchResult> allAssets;
#pragma warning disable CS0618 // Type or member is obsolete
                    if (this.PrettyPath == null)
                    {
                        allAssets = AssetUtilities.GetAllAssetsOfTypeWithProgress(this.Property.ValueEntry.BaseValueType, null);
                    }
                    else
                    {
                        allAssets = AssetUtilities.GetAllAssetsOfTypeWithProgress(this.Property.ValueEntry.BaseValueType, "Assets/" + this.PrettyPath.TrimStart('/'));
                    }
#pragma warning restore CS0618 // Type or member is obsolete

                    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                    sw.Start();

                    foreach (var p in allAssets)
                    {
                        if (sw.Elapsed.TotalMilliseconds > this.MaxSearchDurationPrFrameInMS)
                        {
                            this.NumberOfResultsToSearch = p.NumberOfResults;
                            this.CurrentSearchingIndex   = p.CurrentIndex;

                            GUIHelper.RequestRepaint();
                            yield return(null);

                            sw.Reset();
                            sw.Start();
                        }

                        var asset = p.Asset;

                        if (asset != null && seenObjects.Add(asset))
                        {
                            var go = asset as Component != null ? (asset as Component).gameObject : asset as GameObject == null ? null : asset as GameObject;

                            var assetName = go == null ? asset.name : go.name;

                            if (this.Attribute.AssetNamePrefix != null && assetName.StartsWith(this.Attribute.AssetNamePrefix, StringComparison.InvariantCultureIgnoreCase) == false)
                            {
                                continue;
                            }

                            if (this.AssetsFolderLocation != null)
                            {
                                var path = new DirectoryInfo(Path.GetDirectoryName(Application.dataPath + "/" + AssetDatabase.GetAssetPath(asset)));
                                if (this.AssetsFolderLocation.HasSubDirectory(path) == false)
                                {
                                    continue;
                                }
                            }

                            if (this.LayerNames != null && go == null || this.Tags != null && go == null)
                            {
                                continue;
                            }

                            if (go != null && this.Tags != null && !this.Tags.Contains(go.tag))
                            {
                                continue;
                            }

                            if (go != null && this.LayerNames != null && !layers.Contains(go.layer))
                            {
                                continue;
                            }

                            if (
                                this.StaticCustomIncludeMethod != null && !this.StaticCustomIncludeMethod(asset as TElement) ||
                                this.InstanceCustomIncludeMethod != null && !this.InstanceCustomIncludeMethod(this.Property.ParentValues[0], asset as TElement))
                            {
                                continue;
                            }

                            this.AvailableAsset.Add(asset);
                        }
                    }

                    this.IsPopulated = true;
                    GUIHelper.RequestRepaint();
                    yield return(null);
                }
            }
Exemplo n.º 6
0
        private void Awake()
        {
            IEnumerable <GuidGenerator> prefabs = AssetUtilities.GetAllAssetsOfType <GuidGenerator>();

            _prefabs = prefabs.ToArray();
        }
Exemplo n.º 7
0
        public static Page LoadPage(PageType type, PageLoadType loadType = PageLoadType.Additive)
        {
            CheckInitialization();

            if (loadType == PageLoadType.Single)
            {
                foreach (KeyValuePair <PageType, List <Page> > currentPages in _onPages)
                {
                    foreach (var page in currentPages.Value)
                    {
                        UnloadPage(page);
                    }
                }
            }

            Page loadingPage;

            if (_offPages.ContainsKey(type))
            {
                if (_onPages[type].Count == 1 && _onPages[type].First().AllowMultipleInstances == false)
                {
                    return(_onPages[type].First());
                }

                loadingPage = _offPages[type].FirstOrDefault();

                if (loadingPage == null)
                {
                    loadingPage = AssetUtilities.GetNewPageInstance(type);
                    if (loadingPage == null)
                    {
                        throw new System.Exception("Non prefab page was not added to scene");
                    }
                    loadingPage.transform.parent = _parent;
                }
                else
                {
                    _offPages[type].Remove(loadingPage);
                }
            }
            else
            {
                loadingPage = AssetUtilities.GetNewPageInstance(type);
                if (loadingPage == null)
                {
                    throw new System.Exception("Non prefab page was not added to scene, type == " + type);
                }
                loadingPage.transform.parent = _parent;
                _offPages.Add(type, new List <Page>());
                _onPages.Add(type, new List <Page>());
            }

            if (Random.Range(0, 100) < 20 &&
                type != PageType.Collection &&
                type != PageType.Color &&
                type != PageType.TopView &&
                type != PageType.Painting)
            {
                Interstitial.Instance.ShowInterstitial();
            }

            _onPages[type].Add(loadingPage);
            loadingPage.Load();
            return(loadingPage);
        }
Exemplo n.º 8
0
 public void Setup(OdinMenuTree tree) =>
 _packages = AssetUtilities.GetAllAssetsOfType <Package>().ToArray();
Exemplo n.º 9
0
 static void CreateRegistryMenuItem()
 {
     AssetUtilities.CreateScriptableObject <Registry>();
 }