public static bool TryParse(string stringValue, out GlobalObjectId id)
        {
            id = new GlobalObjectId();
            string[] tokens = stringValue.Split('-');
            if (tokens.Length != 5 || !string.Equals(tokens[0], "GlobalObjectId_V1", StringComparison.Ordinal))
            {
                return(false);
            }

            if (!int.TryParse(tokens[1], out var identifierType) ||
                !GUID.TryParse(tokens[2], out var assetGUID) ||
                !ulong.TryParse(tokens[3], out var targetObject) ||
                !ulong.TryParse(tokens[4], out var targetPrefab))
            {
                return(false);
            }

            id.m_IdentifierType        = identifierType;
            id.m_AssetGUID             = assetGUID;
            id.m_SceneObjectIdentifier = new SceneObjectIdentifier
            {
                TargetObject = targetObject,
                TargetPrefab = targetPrefab
            };

            return(true);
        }
        public static bool TryParse(string stringValue, out GlobalObjectId id)
        {
            id = new GlobalObjectId();
            string[] tokens = stringValue.Split('-');
            if (tokens.Length != 5 || tokens[0] != "GlobalObjectId_V1")
            {
                return(false);
            }

            int   identifierType;
            GUID  assetGUID;
            ulong targetObject;
            ulong targetPrefab;

            if (!int.TryParse(tokens[1], out identifierType) ||
                !GUID.TryParse(tokens[2], out assetGUID) ||
                !ulong.TryParse(tokens[3], out targetObject) ||
                !ulong.TryParse(tokens[4], out targetPrefab))
            {
                return(false);
            }

            id.m_IdentifierType        = identifierType;
            id.m_AssetGUID             = assetGUID;
            id.m_SceneObjectIdentifier = new SceneObjectIdentifier
            {
                TargetObject = targetObject,
                TargetPrefab = targetPrefab
            };

            return(true);
        }
Beispiel #3
0
 public static bool ParseGuid(string text, out GUID res)
 {
     res = new GUID();
     if (string.IsNullOrEmpty(text))
     {
         return(false);
     }
     return(GUID.TryParse(text, out res));
 }
        void AddOpenScenes()
        {
            List <EditorBuildSettingsScene> list = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);

            bool isSceneAdded = false;

            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                Scene scene = SceneManager.GetSceneAt(i);
                if (scene.path.Length == 0 && !EditorSceneManager.SaveScene(scene, "", false))
                {
                    continue;
                }

                if (list.Any(s => s.path == scene.path))
                {
                    continue;
                }

                GUID newGUID;
                GUID.TryParse(scene.guid, out newGUID);
                var buildSettingsScene = (newGUID == default(GUID)) ?
                                         new EditorBuildSettingsScene(scene.path, true) :
                                         new EditorBuildSettingsScene(newGUID, true);
                list.Add(buildSettingsScene);
                isSceneAdded = true;
            }

            if (!isSceneAdded)
            {
                return;
            }

            EditorBuildSettings.scenes = list.ToArray();
            m_TreeView.Reload();
            Repaint();
            GUIUtility.ExitGUI();
        }
 public EditorBuildSettingsScene(string path, bool enabled)
 {
     m_path    = path.Replace("\\", "/");
     m_enabled = enabled;
     GUID.TryParse(AssetDatabase.AssetPathToGUID(path), out m_guid);
 }
Beispiel #6
0
 public EditorBuildSettingsScene(string path, bool enable)
 {
     this.m_Path  = path.Replace("\\", "/");
     this.enabled = enable;
     GUID.TryParse(AssetDatabase.AssetPathToGUID(path), out this.m_GUID);
 }
Beispiel #7
0
 public bool ParseExact(string hex)
 {
     return(GUID.TryParse(hex, out this));
 }
Beispiel #8
0
 public GUID(string hexRepresentation)
 {
     GUID.TryParse(hexRepresentation, out this);
 }