コード例 #1
0
        //call this methof to create an instance of this class
        public static PWGraphBuilder FromGraph(PWGraph graph)
        {
            PWGraphBuilder builder = new PWGraphBuilder();

            builder.graph = graph;

            return(builder);
        }
コード例 #2
0
        public static PWGraphBuilder NewGraph <T>() where T : PWGraph
        {
            if (typeof(T).IsAbstract)
            {
                Debug.LogError("[PWGraphBuilder] Can't instatiate an abstract graph");
                return(null);
            }

            PWGraphBuilder builder = new PWGraphBuilder();

            builder.graph = ScriptableObject.CreateInstance <T>();
            builder.graph.Initialize();
            builder.graph.OnEnable();
            builder.graph.name = Guid.NewGuid().ToString();

            //if the created graph is a biome graph, we manually reset previewGraph
            //to avoid unwished graph asset processing
            if (typeof(T) == typeof(PWBiomeGraph))
            {
                (builder.graph.inputNode as PWNodeBiomeGraphInput).previewGraph = null;
            }

            return(builder);
        }