コード例 #1
0
    void AddOption()
    {
        ComplexMaterial NewOption = new ComplexMaterial();

        _Materials.Add(NewOption);
        Debug.Log("Added Material Option");
    }
コード例 #2
0
        private static void FindBestSolution(WidgetNode nodeList, ComplexMaterial lastMaterial, int drawCall, List <UIWidget> result, ref int bestDrawCall, List <UIWidget> bestResult, int stopDrawCall)
        {
            if (drawCall >= bestDrawCall)
            {
                return;
            }
            if (nodeList == null)
            {
                if (drawCall < bestDrawCall)
                {
                    bestDrawCall = drawCall;
                    bestResult.Clear();
                    bestResult.AddRange(result);
                }
                return;
            }

            var bestNodes = (from node in GetTopWidgetNodesOfList(nodeList)
                             where node.Material == lastMaterial
                             select node).Take(1);

            if (!bestNodes.Any())
            {
                bestNodes = from node in GetTopWidgetNodesOfList(nodeList)
                            group node by node.Material into g
                            select g.First();
            }

            foreach (var node in bestNodes.ToArray())
            {
                nodeList = UnlinkWidgetNodeFromList(nodeList, node);
                foreach (var reverseNode in node.ReverseDependences)
                {
                    --reverseNode.DependenceCount;
                    nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode);
                }
                result.Add(node.Widget);

                FindBestSolution(nodeList, node.Material, lastMaterial == node.Material ? drawCall : drawCall + 1, result, ref bestDrawCall, bestResult, stopDrawCall);

                result.RemoveAt(result.Count - 1);
                foreach (var reverseNode in node.ReverseDependences)
                {
                    ++reverseNode.DependenceCount;
                    nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode);
                }
                nodeList = LinkWidgetNodeToList(nodeList, node);

                if (bestDrawCall == stopDrawCall)
                {
                    break;
                }
            }
        }
コード例 #3
0
        private static void FindBestSolution(WidgetNode nodeList, ComplexMaterial lastMaterial, int drawCall, List<UIWidget> result, ref int bestDrawCall, List<UIWidget> bestResult, int stopDrawCall)
        {
            if (drawCall >= bestDrawCall) return;
            if (nodeList == null)
            {
                if (drawCall < bestDrawCall)
                {
                    bestDrawCall = drawCall;
                    bestResult.Clear();
                    bestResult.AddRange(result);
                }
                return;
            }

            var bestNodes = (from node in GetTopWidgetNodesOfList(nodeList)
                             where node.Material == lastMaterial
                             select node).Take(1);
            if (!bestNodes.Any())
            {
                bestNodes = from node in GetTopWidgetNodesOfList(nodeList)
                            group node by node.Material into g
                            select g.First();
            }

            foreach (var node in bestNodes.ToArray())
            {
                nodeList = UnlinkWidgetNodeFromList(nodeList, node);
                foreach (var reverseNode in node.ReverseDependences)
                {
                    --reverseNode.DependenceCount;
                    nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode);
                }
                result.Add(node.Widget);

                FindBestSolution(nodeList, node.Material, lastMaterial == node.Material ? drawCall : drawCall + 1, result, ref bestDrawCall, bestResult, stopDrawCall);

                result.RemoveAt(result.Count - 1);
                foreach (var reverseNode in node.ReverseDependences)
                {
                    ++reverseNode.DependenceCount;
                    nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode);
                }
                nodeList = LinkWidgetNodeToList(nodeList, node);

                if (bestDrawCall == stopDrawCall) break;
            }
        }