Exemple #1
0
    public static ContainerPriorityFinder LoadContainerPriorityFinderByTag(string tag)
    {
        string strErr = "0";

        try
        {
            ContainerPriorityFinder container = null;

            if (loadedAssetBundle == null)
            {
                Debug.Log("load AssetBundle... " + m_name);
                AssetBundle.UnloadAllAssetBundles(false);
                loadedAssetBundle = AssetBundle.LoadFromFile(AssetBundleDirectory + "/" + m_name);
            }
            if (loadedAssetBundle == null)
            {
                Debug.Log("Failed to load AssetBundle! ");
                return(null);
            }
            var bundle = loadedAssetBundle;

            ContainerPriorityFinder   containerObj  = null;
            ContainerPriorityFinder[] containerObjs = bundle.LoadAllAssets <ContainerPriorityFinder>();

            if (containerObjs == null)
            {
                Debug.Log("containerObjs - null");
            }
            if (containerObjs != null && containerObjs.Length == 0)
            {
                Debug.Log("containerObjs count = 0");
            }

            if (containerObjs != null && containerObjs.Length != 0)
            {
                containerObj = containerObjs.Where(p => p.Tag == tag).FirstOrDefault();
            }

            if (containerObj != null)
            {
                Debug.Log("ContainerPriorityFinder >> " + containerObj.name + " by Tag = " + tag);
            }

            container = containerObj as ContainerPriorityFinder;
            if (container == null)
            {
                Debug.Log("Failed to load ContainerPriorityFinder ! ");
            }

            return(container);
        }
        catch (Exception ex)
        {
            Debug.Log(Storage.EventsUI.ListLogAdd = "###(" + strErr + ") : " + ex.Message);
        }
        return(null);
    }
Exemple #2
0
    public static void LoadContainerPriorityFinderEditor()
    {
        ContainerPriorityFinder cpf = null;

        try
        {
            string name = "ContainerPriorityFinder.asset";
            string pathPriorityContainer = AssetBundleDirectory + "/ScriptableData/" + name;
            cpf = (ContainerPriorityFinder)AssetDatabase.LoadAssetAtPath(pathPriorityContainer, typeof(ContainerPriorityFinder));
        }
        catch (Exception ex)
        {
            Debug.Log("### LoadContainerPriorityFinder : " + ex.Message);
        }
    }
Exemple #3
0
    static void SavePriotitysFinders()
    {
        var selectionPath = AssetDatabase.GetAssetPath(Selection.activeObject);
        ContainerPriorityFinder containerPriorityFinder = Selection.activeObject as ContainerPriorityFinder;

        //string assetBundleDirectory = m_assetBundleDirectory + "/ContainerPriorityFinder.asset";
        string assetBundleDirectory = AssetBundleDirectory + "/ContainerPriorityFinder";

        // Create a simple material asset

        //Material material = new Material(Shader.Find("Specular"));
        //ContainerPriorityFinder containerPriorityFinder = Storage.Person.ContainerPrioritys;

        AssetDatabase.CreateAsset(containerPriorityFinder, assetBundleDirectory);

        AssetDatabase.SaveAssets();

        // Add an animation clip to it
        //AnimationClip animationClip = new AnimationClip();
        //animationClip.name = "My Clip";
        //AssetDatabase.AddObjectToAsset(animationClip, material);

        // Reimport the asset after adding an object.
        // Otherwise the change only shows up when saving the project
        //AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(animationClip));

        // Print the path of the created asset
        //Debug.Log(AssetDatabase.GetAssetPath(material));

        //--------------
        //var asset = ScriptableObject.CreateInstance<LocalizationData>();

        //AssetDatabase.CreateAsset(asset, path);
        //AssetDatabase.SaveAssets();

        //EditorUtility.FocusProjectWindow();

        Selection.activeObject = containerPriorityFinder;
        //---------------------
    }
Exemple #4
0
    public static Dictionary <SaveLoadData.TypePrefabs, PriorityFinder> GetPrioritys(ContainerPriorityFinder p_containerPrioritys, string tag)
    {
        string strErr = "";
        Dictionary <SaveLoadData.TypePrefabs, PriorityFinder> result = null;

        try
        {
            Storage.EventsUI.ListLogAdd = "...LoadPriorityPerson....";
            strErr = "1";
            if (p_containerPrioritys == null)
            {
                p_containerPrioritys = ScriptableObjectUtility.LoadContainerPriorityFinderByTag(tag);
                if (p_containerPrioritys == null)
                {
                    Storage.EventsUI.ListLogAdd = "ContainerPriority is null";
                    return(null);
                }
            }
            strErr = "2";
            if (p_containerPrioritys.CollectionPriorityFinder == null)
            {
                Storage.EventsUI.ListLogAdd = "ContainerPriority.CollectionPriorityFinder is null";
                return(null);
            }
            strErr = "3";
            Storage.EventsUI.ListLogAdd = "CollectionPriorityFinder Count = " + p_containerPrioritys.CollectionPriorityFinder.Count();
            strErr = "4";
            result = new Dictionary <SaveLoadData.TypePrefabs, PriorityFinder>();
            foreach (var prior in p_containerPrioritys.CollectionPriorityFinder)
            {
                result.Add(prior.TypeObserver, prior);
            }
        }
        catch (Exception ex)
        {
            Storage.EventsUI.ListLogAdd = "##### GetPrioritys : #" + strErr + "  " + ex.Message;
        }
        return(result);
    }
Exemple #5
0
    public static void LoadAssetBundleCell()
    {
        string strErr = "0";

        try
        {
            ContainerPriorityFinder container = null;

            if (loadedAssetBundle == null)
            {
                Debug.Log("load AssetBundle... " + m_name);
                AssetBundle.UnloadAllAssetBundles(false);
                loadedAssetBundle = AssetBundle.LoadFromFile(AssetBundleDirectory + "/" + m_name);
            }
            if (loadedAssetBundle == null)
            {
                Debug.Log("Failed to load AssetBundle! ");
            }
        }
        catch (Exception ex)
        {
            Debug.Log(Storage.EventsUI.ListLogAdd = "###(" + strErr + ") : " + ex.Message);
        }
    }
Exemple #6
0
    static void LoadPriotitysFinders()
    {
        if (ScriptableObjectUtility.loadedAssetBundle == null)
        {
            Debug.Log("load AssetBundle... " + m_name);
            AssetBundle.UnloadAllAssetBundles(false);
            loadedAssetBundle = AssetBundle.LoadFromFile(AssetBundleDirectory + "/" + m_name);
        }
        if (ScriptableObjectUtility.loadedAssetBundle == null)
        {
            Debug.Log("Failed to load AssetBundle! ");
            return;
        }
        var bundle      = loadedAssetBundle;
        var namesAssets = bundle.GetAllAssetNames();

        if (namesAssets.Length == 0)
        {
            Debug.Log("loadedAssetBundle.AllAssetNames = 0");
        }
        //string assetFirts = "";
        //foreach (var nameAss in namesAssets)
        //{
        //    assetFirts = nameAss;
        //    Debug.Log(nameAss);
        //    break;
        //}
        //if(bundle.Contains(assetFirts))
        //{
        //    Debug.Log("Exist assetFirts = " + assetFirts);
        //}

        ContainerPriorityFinder containerObj = null;

        ContainerPriorityFinder[] containerObjs = bundle.LoadAllAssets <ContainerPriorityFinder>();

        if (containerObjs == null)
        {
            Debug.Log("containerObjs - null");
        }
        if (containerObjs != null && containerObjs.Length == 0)
        {
            Debug.Log("containerObjs count = 0");
        }

        if (containerObjs != null && containerObjs.Length != 0)
        {
            containerObj = containerObjs[0];
        }

        if (containerObj != null)
        {
            Debug.Log("ContainerPriorityFinder >> " + containerObj.name);
        }

        ContainerPriorityFinder container = containerObj as ContainerPriorityFinder;

        if (container == null)
        {
            Debug.Log("Failed to load ContainerPriorityFinder ! ");
            return;
        }
        Debug.Log("Load ContainerPriorityFinder OK ! size :" + container.CollectionPriorityFinder.Length);
    }