コード例 #1
0
    static void AutoFillArtCollection()
    {
        try
        {
            Dictionary <string, ArtCollection.Group> groupMap = new Dictionary <string, ArtCollection.Group>();
            foreach (var g in ArtCollection.Instance.groups)
            {
                groupMap[I18n.Get(g.name).ToLower()] = g;
            }

            string[] dirs = Directory.GetDirectories(Application.dataPath + '/' + Paths.AssetResArtworksNoPrefix);
            for (int i = 0; i < dirs.Length; ++i)
            {
                string name      = Path.GetFileName(dirs[i]);
                string groupName = name;
                var    match     = Regex.Match(name, @"(\D+)");
                if (match.Success)
                {
                    groupName = match.Groups[1].Value;
                }

                EditorUtility.DisplayProgressBar("Auto Fill ArtCollection", name, (float)i / dirs.Length);

                var group = ArtCollection.Instance.groups.Find(v => 0 == string.Compare(I18n.Get(v.name), groupName, true));
                if (null == group)
                {
                    group = ArtCollection.Instance.groups.Find(v => I18n.Get(v.name) == "Default");
                }

                var item = group.items.Find(v => v.name == name);
                if (null == item)
                {
                    item      = new ArtCollection.Item();
                    item.name = name;
                    group.items.Add(item);
                }

                if (string.IsNullOrEmpty(item.bgColor))
                {
                    var assetPath = string.Format("{0}/{1}/{1}.prefab", Paths.AssetResArtworks, item.name);
                    var go        = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath);
                    var color     = PuzzleBackground.AvarageColor(go.GetComponent <PolyGraph>());
                    item.bgColor = Utils.ColorToString(color);
                }
            }

            EditorUtility.DisplayProgressBar("Auto Fill ArtCollection", "Saving json", 1f);
            string path = string.Format("{0}/Res/{1}/ArtCollection.json", Application.dataPath, Paths.Configs);
            string json = JsonUtility.ToJson(ArtCollection.Instance, true);
            File.WriteAllText(path, json, Encoding.UTF8);
        }
        catch (Exception e)
        {
            Debug.LogException(e);
        }
        finally
        {
            EditorUtility.ClearProgressBar();
        }
    }
コード例 #2
0
ファイル: PuzzleInitState.cs プロジェクト: llisper/PolyGame
    void LoadBackgroundQuad()
    {
        var go = PuzzleBackground.Create(Data.puzzleObject, Data.playgroundBounds);

        go.layer = Layers.Debris;
        go.transform.SetParent(Data.transform, true);
    }
コード例 #3
0
ファイル: PuzzleSnapshot.cs プロジェクト: llisper/PolyGame
    void InitBackground(bool takingInitialSnapshot)
    {
        Vector2 pos = graph.size;

        pos = pos / 2f;
        var bounds = Utils.CalculateBounds(pos, ssCamera.aspect, ssCamera.orthographicSize);

        backgroundObject       = PuzzleBackground.Create(graph, bounds, takingInitialSnapshot, takingInitialSnapshot);
        backgroundObject.layer = Layers.Snapshot;
        backgroundObject.transform.SetParent(transform, true);
    }