예제 #1
0
        private Object  TryFetchFromProject(string path, UnityObject unityObject)
        {
            if (unityObject.instanceID == 0)
            {
                return(null);
            }

            Object           localAsset;
            ImportAssetState state = this.unityData.GetAssetFromImportParameters(unityObject.instanceID, out localAsset, true);

            if (state == ImportAssetState.Waiting || state == ImportAssetState.Requesting)
            {
                throw new IncompleteGameObjectException(path, unityObject.type, unityObject.instanceID, this.parent.instanceID, this.instanceID);
            }
            //throw new IncompleteGameObjectException();

            if (state == ImportAssetState.Ready)
            {
                return(localAsset);
            }

            string name = this.unityData.GetResourceName(unityObject.type, unityObject.instanceID);

            if (name == null)
            {
                throw new IncompleteGameObjectException(path, unityObject.type, unityObject.instanceID, this.parent.instanceID, this.instanceID);
            }

            Object[] assets;

            if (ClientComponent.cachedResources.TryGetValue(unityObject.type, out assets) == false)
            {
                assets = Resources.FindObjectsOfTypeAll(unityObject.type);
                ClientComponent.cachedResources.Add(unityObject.type, assets);
            }

            for (int i = 0; i < assets.Length; i++)
            {
                // TODO Maybe improve the comparison with more than name?
                if (assets[i] != null && assets[i].name == name)
                {
                    if (assets[i].hideFlags == HideFlags.None && AssetDatabase.IsForeignAsset(assets[i]) == false && AssetDatabase.IsNativeAsset(assets[i]) == false)
                    {
                        break;
                    }
                    this.unityData.ImportAsset(path, unityObject.type, unityObject.instanceID, this.parent.instanceID, this.instanceID, assets[i]);
                    return(assets[i]);
                }
            }

            throw new IncompleteGameObjectException(path, unityObject.type, unityObject.instanceID, this.parent.instanceID, this.instanceID, true);
        }
예제 #2
0
        public bool     VerifyComponentsReady(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> globalRefs, Client client)
        {
            if (this.componentsVerified == false)
            {
                this.componentsVerified = this.rootGameObject.VerifyComponentsReady(hierarchy, globalRefs, this, client);
            }
            else if (this.importsConfirmed == false)
            {
                for (int i = 0; i < this.importParameters.Count; i++)
                {
                    if (this.importParameters[i].ParametersConfirmed == false)
                    {
                        return(false);
                    }
                    else
                    {
                        this.importParameters[i].CheckImportState();
                    }
                }

                this.importsConfirmed = true;
            }
            else if (this.assetsReady == false)
            {
                for (int i = 0; i < this.importParameters.Count; i++)
                {
                    ImportAssetState state = this.importParameters[i].CheckImportState();

                    if (state != ImportAssetState.Ready && state != ImportAssetState.DoesNotExist)
                    {
                        return(false);
                    }
                }

                this.assetsReady = true;
            }

            return(this.componentsVerified == true && this.importsConfirmed == true && this.assetsReady == true);
        }