Пример #1
0
        static void SaveAndUpdateAssemblyDefinitionReferenceState(AssemblyDefinitionReferenceState state)
        {
            CustomScriptAssemblyReferenceData data = new CustomScriptAssemblyReferenceData();

            if (state.asset != null)
            {
                data.reference = state.useGUIDs ? CompilationPipeline.GUIDToAssemblyDefinitionReferenceGUID(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(state.reference.asset))) : state.reference.name;
            }

            var json = CustomScriptAssemblyReferenceData.ToJson(data);

            File.WriteAllText(state.path, json);
            AssetDatabase.ImportAsset(state.path);
        }
Пример #2
0
        static void LoadAssemblyDefinitionReferenceState(AssemblyDefinitionReferenceState state, string path)
        {
            var asset = AssetDatabase.LoadAssetAtPath <AssemblyDefinitionReferenceAsset>(path);

            if (asset == null)
            {
                return;
            }

            var data = CustomScriptAssemblyReferenceData.FromJson(asset.text);

            if (data == null)
            {
                return;
            }

            state.asset     = asset;
            state.useGUIDs  = string.IsNullOrEmpty(data.reference) || CompilationPipeline.GetAssemblyDefinitionReferenceType(data.reference) == AssemblyDefinitionReferenceType.Guid;
            state.reference = new AssemblyDefinitionImporterInspector.AssemblyDefinitionReference {
                name = data.reference, serializedReference = data.reference
            };
            state.reference.Load(data.reference, state.useGUIDs);
        }