Example #1
0
        public PrefabComponent(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> existingRefs, PrefabConstruct prefab, ClientComponent component)
        {
            this.component = component;

            for (int i = 0; i < this.component.fields.Length; i++)
            {
                PrefabField field = this.FetchUnityObjectReferences(hierarchy, existingRefs, prefab, this.component.fields[i].name, this.component.fields[i].value);

                if (field != null)
                {
                    field.UpdateIsSupported();
                    if (field.isSupported == true)
                    {
                        this.hasImportableAssets = true;
                    }

                    PrefabComponent.pool.Add(field);
                }
            }

            if (PrefabComponent.pool.Count > 0)
            {
                this.fields = PrefabComponent.pool.ToArray();
                PrefabComponent.pool.Clear();
            }
        }
Example #2
0
        public void     AddChild(PrefabField child)
        {
            this.open = true;

            if (this.children == null)
            {
                this.children = new List <PrefabField>();
            }
            this.children.Add(child);
        }
Example #3
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);
        }