Exemplo n.º 1
0
        /// <summary>
        /// Builds a dictionary of localizable text items in the scene.
        /// </summary>
        protected Dictionary <string, TextItem> FindTextItems()
        {
            Dictionary <string, TextItem> textItems = new Dictionary <string, TextItem>();

            // Add localizable commands in same order as command list to make it
            // easier to localise / edit standard text.
            var flowcharts = GameObject.FindObjectsOfType <Flowchart>();

            for (int i = 0; i < flowcharts.Length; i++)
            {
                var flowchart = flowcharts[i];
                var blocks    = flowchart.GetComponents <Block>();

                for (int j = 0; j < blocks.Length; j++)
                {
                    var block       = blocks[j];
                    var commandList = block.CommandList;
                    for (int k = 0; k < commandList.Count; k++)
                    {
                        var          command     = commandList[k];
                        ILocalizable localizable = command as ILocalizable;
                        if (localizable != null)
                        {
                            TextItem textItem = new TextItem();
                            textItem.standardText = localizable.GetStandardText();
                            textItem.description  = localizable.GetDescription();
                            textItems[localizable.GetStringId()] = textItem;
                        }
                    }
                }
            }

            // Add everything else that's localizable (including inactive objects)
            UnityEngine.Object[] objects = Resources.FindObjectsOfTypeAll(typeof(Component));
            for (int i = 0; i < objects.Length; i++)
            {
                var          o           = objects[i];
                ILocalizable localizable = o as ILocalizable;
                if (localizable != null)
                {
                    string stringId = localizable.GetStringId();
                    if (textItems.ContainsKey(stringId))
                    {
                        // Already added
                        continue;
                    }
                    TextItem textItem = new TextItem();
                    textItem.standardText = localizable.GetStandardText();
                    textItem.description  = localizable.GetDescription();
                    textItems[stringId]   = textItem;
                }
            }

            return(textItems);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Builds a dictionary of localizable text items in the scene.
        /// </summary>
        protected Dictionary <string, TextItem> FindTextItems()
        {
            Dictionary <string, TextItem> textItems = new Dictionary <string, TextItem>();

            // Add localizable commands in same order as command list to make it
            // easier to localise / edit standard text.
            var flowcharts = GameObject.FindObjectsOfType <Flowchart>();

            foreach (var flowchart in flowcharts)
            {
                var blocks = flowchart.GetComponents <IBlock>();
                foreach (var block in blocks)
                {
                    foreach (var command in block.CommandList)
                    {
                        ILocalizable localizable = command as ILocalizable;
                        if (localizable != null)
                        {
                            TextItem textItem = new TextItem();
                            textItem.standardText = localizable.GetStandardText();
                            textItem.description  = localizable.GetDescription();
                            textItems[localizable.GetStringId()] = textItem;
                        }
                    }
                }
            }

            // Add everything else that's localizable (including inactive objects)
            UnityEngine.Object[] objects = Resources.FindObjectsOfTypeAll(typeof(Component));
            foreach (UnityEngine.Object o in objects)
            {
                ILocalizable localizable = o as ILocalizable;
                if (localizable != null)
                {
                    string stringId = localizable.GetStringId();
                    if (textItems.ContainsKey(stringId))
                    {
                        // Already added
                        continue;
                    }

                    TextItem textItem = new TextItem();
                    textItem.standardText = localizable.GetStandardText();
                    textItem.description  = localizable.GetDescription();
                    textItems[stringId]   = textItem;
                }
            }

            return(textItems);
        }
Exemplo n.º 3
0
        /**
         * Builds a dictionary of localizable text items in the scene.
         */
        protected Dictionary <string, TextItem> FindTextItems()
        {
            Dictionary <string, TextItem> textItems = new Dictionary <string, TextItem>();

            // Add localizable commands in same order as command list to make it
            // easier to localise / edit standard text.
            Flowchart[] flowcharts = GameObject.FindObjectsOfType <Flowchart>();
            foreach (Flowchart flowchart in flowcharts)
            {
                Block[] blocks = flowchart.GetComponentsInChildren <Block>();
                foreach (Block block in blocks)
                {
                    foreach (Command command in block.commandList)
                    {
                        ILocalizable localizable = command as ILocalizable;
                        if (localizable != null)
                        {
                            TextItem textItem = new TextItem();
                            textItem.standardText = localizable.GetStandardText();
                            textItem.description  = localizable.GetDescription();
                            textItems[localizable.GetStringId()] = textItem;
                        }
                    }
                }
            }

            // Add everything else that's localizable
            Component[] components = GameObject.FindObjectsOfType <Component>();
            foreach (Component component in components)
            {
                ILocalizable localizable = component as ILocalizable;
                if (localizable != null)
                {
                    string stringId = localizable.GetStringId();
                    if (textItems.ContainsKey(stringId))
                    {
                        // Already added
                        continue;
                    }

                    TextItem textItem = new TextItem();
                    textItem.standardText = localizable.GetStandardText();
                    textItem.description  = localizable.GetDescription();
                    textItems[stringId]   = textItem;
                }
            }

            return(textItems);
        }