Пример #1
0
        private PrefabField     FetchUnityObjectReferences(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> globalRefs, PrefabConstruct prefab, string name, object value)
        {
            UnityObject uo = value as UnityObject;

            if (uo != null)
            {
                if (uo.instanceID == 0)
                {
                    return(null);
                }

                AssetImportParameters importParameters = null;

                // AssetImportParameters must be known in 3 places to be reused: global, prefab & fields.
                for (int i = 0; i < prefab.importParameters.Count; i++)
                {
                    if (prefab.importParameters[i].instanceID == uo.instanceID)
                    {
                        importParameters = prefab.importParameters[i];
                        break;
                    }
                }

                if (importParameters == null)
                {
                    for (int i = 0; i < globalRefs.Count; i++)
                    {
                        if (globalRefs[i].instanceID == uo.instanceID)
                        {
                            importParameters = globalRefs[i];
                            break;
                        }
                    }

                    if (importParameters != null)
                    {
                        prefab.importParameters.Add(importParameters);
                    }
                }

                if (importParameters == null)
                {
                    Debug.Log("C");
                    importParameters = new AssetImportParameters(hierarchy, name, uo.type, this.component.parent.instanceID, this.component.instanceID, uo.instanceID, RemoteUtility.GetImportAssetTypeSupported(uo.type) != null, null)
                    {
                        prefabPath = Path.GetDirectoryName(prefab.path)
                    };
                    prefab.importParameters.Add(importParameters);
                    globalRefs.Add(importParameters);
                }
                else
                {
                    importParameters.originPath.Add(new AssetImportParameters.MyClass()
                    {
                        gameObjectInstanceID = this.component.parent.instanceID, componentInstanceID = this.component.instanceID, path = name
                    });
                }

                return(new PrefabField(name, importParameters));
            }

            ClientClass gc = value as ClientClass;

            if (gc != null)
            {
                PrefabField field = null;

                for (int j = 0; j < gc.fields.Length; j++)
                {
                    PrefabField child = this.FetchUnityObjectReferences(hierarchy, globalRefs, prefab, gc.fields[j].name, gc.fields[j].value);

                    if (child != null)
                    {
                        if (field == null)
                        {
                            field = new PrefabField(name);
                        }
                        field.AddChild(child);
                    }
                }

                return(field);
            }

            ArrayData a = value as ArrayData;

            if (a != null && a.array != null)
            {
                PrefabField field = null;

                for (int j = 0; j < a.array.Length; j++)
                {
                    PrefabField child = this.FetchUnityObjectReferences(hierarchy, globalRefs, prefab, j.ToCachedString(), a.array.GetValue(j));

                    if (child != null)
                    {
                        if (field == null)
                        {
                            field = new PrefabField(name);
                        }
                        field.AddChild(child);
                    }
                }

                return(field);
            }

            return(null);
        }
Пример #2
0
 public PrefabField(string name, AssetImportParameters importParameters)
 {
     this.name             = Utility.NicifyVariableName(name);
     this.importParameters = importParameters;
     this.isSupported      = this.importParameters.isSupported;
 }