示例#1
0
        public override void OnPreBake()
        {
            if (Configuration == null)
            {
                return;
            }

            var existingComponents = new List <ConnectionComponent>(Components);

            Components.Clear();
            for (int i = 0; i < Configuration.Components.Count; i++)
            {
                var componentConfiguration            = Configuration.Components[i];
                ConnectionComponent existingComponent = null;
                for (int j = 0; j < existingComponents.Count; j++)
                {
                    var config = existingComponents[j];
                    if (config.Configuration.Configuration == Configuration &&
                        config.Configuration.ComponentGUID == componentConfiguration.GUID)
                    {
                        existingComponent = config;
                        existingComponents.Remove(config);
                        break;
                    }
                }
                if (existingComponent == null)
                {
                    existingComponent = gameObject.AddComponent(componentConfiguration.GetMonoType()) as ConnectionComponent;
                    existingComponent.SetData(this,
                                              new ComponentConfigurationRef(Configuration, componentConfiguration.GUID));
                }
                Components.Add(existingComponent);
            }

            for (int i = 0; i < existingComponents.Count; i++)
            {
                var connectionComponent = existingComponents[i];
                connectionComponent.Destroy();
                DestroyImmediate(connectionComponent);
            }
        }
示例#2
0
 public virtual void CopyTo(ConnectionComponent otherRo)
 {
     otherRo.Configuration = Configuration.JSONClone();
 }