/// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the value to convert into an instance of <see cref="ClusterResources" />.</param>
 /// <returns>
 /// an instance of <see cref="ClusterResources" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         ClusterResources.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new ClusterResources
         {
             Config = ClusterConfigSpecTypeConverter.ConvertFrom(sourceValue.Config),
             Network = ClusterNetworkTypeConverter.ConvertFrom(sourceValue.Network),
             RuntimeStatusList = sourceValue.RuntimeStatusList,
         });
     }
     catch
     {
     }
     return(null);
 }
    static void CreateScriptObject()
    {
        ClusterResources res = ScriptableObject.CreateInstance <ClusterResources>();

        res.name = "SceneManager";
        res.clusterProperties = new List <SceneStreaming>();
        AssetDatabase.CreateAsset(res, "Assets/ClusterMatResources.asset");
        AssetDatabase.Refresh();
    }
示例#3
0
    public void LoadScene(string name)
    {
        ClusterResources res = _asset.res;
        SceneStreaming   ss  = res.GetSceneStreaming(name);

        if (ss == null)
        {
            Debug.LogError("没有取到场景资源,请检查ClusterMatResource");
        }
        VirtualMaterial vm = ss.vm;

        _properties       = vm.allProperties.ToArray();
        _perprotiesBuffer = new ComputeBuffer(_properties.Length, sizeof(MaterialProperties));
        _perprotiesBuffer.SetData(_properties);

        for (int i = 0; i < vm.albedoIDs.Count; i++)
        {
            string  texPath = "Scenes/" + name + ClusterComponents.PATH_TEX + vm.albedoNames[i];
            Texture texture = ResourceManager.instance.Load <Texture>(texPath);
            Shader.SetGlobalTexture(vm.albedoIDs[i].ToString(), texture);
        }
    }