コード例 #1
0
    private static void SaveDependencies()
    {
        Objects = new List<KeyValuePair<string, string>>();

        Dependencies = new List<KeyValuePair<string, List<string>>>();

        foreach (var obj in Selection.objects)
        {
            List<string> deps = new List<string>();

            string objPath = AssetDatabase.GetAssetPath(obj);
            objPath = objPath.Replace("Assets/Resources/", "");
            int fileExtPos = objPath.LastIndexOf('.');
            objPath = objPath.Substring(0, fileExtPos);
            Objects.Add(new KeyValuePair<string, string>(obj.name, objPath));

            var dependencies = EditorUtility.CollectDependencies(new[] { obj });
            foreach (var d in dependencies)
            {
                string path = AssetDatabase.GetAssetPath(d);
                if (path.Contains("Assets/Resources/"))
                {
                    path = path.Replace("Assets/Resources/", "");
                    fileExtPos = path.LastIndexOf('.');
                    path = path.Substring(0, fileExtPos);
                    
                    if (d is Texture2D || d is Material || d is Shader)
                    {
                        deps.Add(path);
                    }
                }
            }
            Dependencies.Add(new KeyValuePair<string, List<string>>(obj.name, deps));
        }

        JsonRoot root = new JsonRoot();
        int count = 0;

        foreach (var obj in Objects)
        {
            JsonClass jsonObject = new JsonClass(count.ToString());

            jsonObject.AddObjects(new JsonValue(ObjectFromCache.JsonName, obj.Key));
            jsonObject.AddObjects(new JsonValue(ObjectFromCache.JsonPath, obj.Value));
            jsonObject.AddObjects(new JsonArray(ObjectFromCache.JsonDependencies, Dependencies.Find((d)=> obj.Key == d.Key).Value));

            root.AddObjects(jsonObject);
            count++;
        }

        string filepath = EditorUtility.SaveFilePanel("Save dependencies for selected objects", "Assets", "Dependencies", "json");

        File.WriteAllText(filepath, root.ToString(), Encoding.UTF8);
    }
コード例 #2
0
ファイル: RandomSequence.cs プロジェクト: arahis/Swiper
 public JsonArray GetJson(string jsonArrayName)
 {
     List<JsonClass> classList = new List<JsonClass>();
     foreach (var obj in _randomObjects)
     {
         JsonClass jclass = new JsonClass();
         jclass.AddObjects(new JsonValue("index", obj.Index), new JsonValue("probability", obj.Probability));
         classList.Add(jclass);
     }
     return new JsonArray(jsonArrayName, classList);
 }
コード例 #3
0
ファイル: TransformBase.cs プロジェクト: arahis/Swiper
    public virtual JsonClass GetJson()
    {
        var json = new JsonClass();

        json.AddObjects(new JsonValue("type", Type));
        json.AddObjects(new JsonValue("play_on_awake", PlayOnAwake));
        json.AddObjects(new JsonValue("is_local", IsLocal));
        json.AddObjects(new JsonValue("is_dependent", IsDependent));
        json.AddObjects(new JsonArray("target", Target));
        json.AddObjects(new JsonValue("time", Time));
        json.AddObjects(new JsonValue("ease", Ease));
        json.AddObjects(new JsonValue("is_loop", IsLoop));
        json.AddObjects(new JsonValue("loops", Loops));
        json.AddObjects(new JsonValue("loop_type", LoopType));

        return json;
    }
コード例 #4
0
ファイル: BlockPrices.cs プロジェクト: arahis/Swiper
    public JsonClass GetJson(string jsonClassName)
    {
        JsonClass json = new JsonClass(jsonClassName);

        json.AddObjects(new JsonValue("limit_type", LimitType.ToString()));
        switch (LimitType)
        {
            case LimitType.Moves:
                json.AddObjects(new JsonValue("limit", Moves));
                break;
            case LimitType.Time:
                json.AddObjects(new JsonValue("limit", TimeSpan));
                break;
        }

        List<JsonClass> list = new List<JsonClass>();
        foreach (var p in _prices)
        {
            JsonClass c = new JsonClass();
            c.AddObjects(new JsonValue("index", p.Key), new JsonValue("price", p.Value));
            list.Add(c);
        }

        json.AddObjects(new JsonArray("prices", list));
        json.AddObjects(new JsonArray("stars_levels", StarsLevels));

        return json;
    }