Exemplo n.º 1
0
        /**
         * Creates a simple map of processed material name to material, so that we
         * can retrieve a material quickly based on a key name instead of a linear search.
         *
         * @param pMaterialSet the material to create a map for
         */
        private static void createMaterialMap(MaterialSet pMaterialSet)
        {
            log("Processing " + pMaterialSet.description);
            log("Mapping materials:");
            log("");

            _key2MaterialMap.Clear();
            string key = "";

            foreach (Material material in pMaterialSet.materials)
            {
                key = convertToKey(material.name);
                log("[" + material.name + "] => [" + key + "]");
                _key2MaterialMap[key] = material;
            }
        }
Exemplo n.º 2
0
        /**
         * Tries to map each material in the given materialset to the given gameobjects.
         *
         * @param pMaterialSet the materialset containing all materials to map
         * @param pGameObjects a collection of GameObject to change materials of
         */
        public static string MapMaterialSetToGameObjects(MaterialSet pMaterialSet, IEnumerable <GameObject> pGameObjects)
        {
            clearLog();

            if (pMaterialSet == null)
            {
                log("No valid material set provided.");
            }
            else
            {
                createMaterialMap(pMaterialSet);
                processAllGameObjects(pGameObjects);
            }

            return(logContents());
        }
Exemplo n.º 3
0
        private void updateMaterialSet()
        {
            _currentMaterialSetIndex = ((_currentMaterialSetIndex % _materialSetCount) + _materialSetCount) % _materialSetCount;

            _materialDropdown.value = (_currentMaterialSetIndex + 1);

            MaterialSet materialSet = _materialSetCollection.materialSets[_currentMaterialSetIndex];
            string      logInfo     = MaterialSetUtility.MapMaterialSetToGameObjects(materialSet, _diceAsGameObjects);

            if (logInfo != null)
            {
                Debug.Log(logInfo);
            }
            else
            {
                Debug.Log("Done processing, for more info, define the MSUD_ON scripting symbol in the player settings.");
            }
        }
Exemplo n.º 4
0
        private void doMaterialSetDropAreaGUI()
        {
            Event evt = Event.current;
            Rect drop_area = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));
            GUI.Box(drop_area, "Drag a MaterialSet here", _centeredBox);

            switch (evt.type)
            {
                case EventType.DragUpdated:
                    if (!drop_area.Contains(evt.mousePosition)) return;
                    if (DragAndDrop.objectReferences.Length != 1) return;
                    if (!(DragAndDrop.objectReferences[0] is MaterialSet)) return;
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    DragAndDrop.AcceptDrag();
                    break;

                case EventType.DragPerform:
                    MaterialSet materialSet = DragAndDrop.objectReferences[0] as MaterialSet;
                    GameObject[] dice = targets.Select(x => (x as DieSides).gameObject).ToArray<GameObject>();
                    _materialInfo = MaterialSetUtility.MapMaterialSetToGameObjects(materialSet, dice);
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                    break;
            }
        }