示例#1
0
        //How do you retrieve a schmeatic from a gameobject, the default is specific to MCS
        public AssetSchematic GetSchematicFromGameObjectDefault(GameObject go, Dictionary <string, AssetSchematic> schematicLookup)
        {
            MCSItemModel itemModel = go.GetComponent <MCSItemModel>();

            if (itemModel != null)
            {
                return(itemModel.schematic);
            }

            //we couldn't find it on the gameobject, check in our dictionary
            AssetSchematic schematic;
            string         guid = GetGUIDFromGameObject(go);

            if (guid != null)
            {
                if (schematicLookup.TryGetValue(guid, out schematic))
                {
                    //we found it in our main dictinoary
                    //UnityEngine.Debug.Log("Found Schematic via guid: " + guid + " | " + go.name);
                    return(schematic);
                }
            }

            //couldn't find it via a guid, try the path stripping the root node's name out first
            string path = GetPathFromGameObject(go, true);

            if (!String.IsNullOrEmpty(path))
            {
                if (schematicLookup.TryGetValue(path, out schematic))
                {
                    //we found it in our main dictionary
                    //UnityEngine.Debug.LogWarning("Found Schematic via Path: " + guid + " | " + path + " | " + go.name);
                    return(schematic);
                }
            }
            //same thing but do not strip root (GL Stockings Left/glstockings_15340_left_LOD_0/glstockings_15340_left_LOD0 vs glstockings_15340_left_LOD_0/glstockings_15340_left_LOD0)
            path = GetPathFromGameObject(go, false);
            if (!String.IsNullOrEmpty(path))
            {
                if (schematicLookup.TryGetValue(path, out schematic))
                {
                    //we found it in our main dictionary
                    //UnityEngine.Debug.LogWarning("Found Schematic via Path: " + guid + " | " + path + " | " + go.name);
                    return(schematic);
                }
            }

            //UnityEngine.Debug.Log("GetSchmeatic: " + guid + " | " + path + " | " + go.name);

            //couldn't find it
            return(null);
        }
示例#2
0
        //get a mcs id (guid string, not a real guid) from the gameobject by looking at components
        public string GetGUIDFromGameObjectDefault(GameObject go)
        {
            string guid = null;

            //Try to find the guid by an attached component
            MCSProperty property = go.GetComponent <MCSProperty>();

            if (property != null)
            {
                guid = property.mcs_id;
            }

            //is it still null?
            if (guid == null)
            {
                MCSItemModel model = go.GetComponent <MCSItemModel>();
                if (model != null)
                {
                    guid = model.schematic.origin_and_description.mcs_id;
                }
            }

            return(guid);
        }