private void Load(string filePath)
        {
            w = ScriptableObject.CreateInstance <Wardrobe>();
            int    lastSlash = filePath.LastIndexOf('/');
            string fileName  = filePath.Substring(lastSlash + 1, filePath.Length - ".asset".Length - lastSlash - 1);

            UnityEngine.Object file = Resources.Load <Wardrobe>(fileName);
            if (file != null)
            {
                w = (Wardrobe)file;
            }
            else
            {
                Debug.LogWarning("File not found - will create new one.");
            }

            showVersion = new List <bool> [w.locations.Length];
            showLayers  = new List <List <bool> > [w.locations.Length];
            showPalette = new List <bool>();
            for (int i = 0; i < w.locations.Length; i++)
            {
                showVersion[i] = new List <bool>();
                showLayers[i]  = new List <List <bool> >();
            }
        }
示例#2
0
        public CharacterSetting(Transform _host)
        {
            host = _host;

            Wardrobe w = Wardrobe.Singleton;

            locations = new FeatureSetting[6];
            for (int i = 0; i < locations.Length; i++)
            {
                locations[i] = new FeatureSetting(w.locations[i]);
            }
            Init();
        }
        //[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            Wardrobe w    = Wardrobe.Singleton;
            int      hash = this.GetHashCode();

            Debug.Log(hash + "  " + Time.time);
            for (int i = 0; i < w.locations.Length; i++)
            {
                for (int j = 0; j < w.locations[i].versions.Count; j++)
                {
                    Version v = w.locations[i].versions[j];
                    if (v.GetHashCode() == hash)
                    {
                        Debug.Log("MATCH: " + v.GetHashCode());
                        info.AddValue("location", i);
                        info.AddValue("version", j);
                        return;
                    }
                }
            }
            Debug.Log("This shouldn't happen");
        }
        List <TabView> BuildTabs()
        {
            Wardrobe w = ScriptableObject.CreateInstance <Wardrobe>();

            w = Wardrobe.Singleton;
            List <TabView> t = new List <TabView>();

            // Build 'Hair' tab
            TabView     hair     = new TabView();
            FeatureView hairHair = new FeatureView(w.locations[1], cs.locations[1]);

            hair.features.Add(hairHair);
            t.Add(hair);

            // Build 'Body' Tab
            TabView     body = new TabView();
            FeatureView skin = new FeatureView(w.locations[0], cs.locations[0]);
            FeatureView eyes = new FeatureView(w.locations[2], cs.locations[2]);

            body.features.Add(skin);
            body.features.Add(eyes);
            t.Add(body);

            // Build 'Clothes' tab
            TabView     clothes = new TabView();
            FeatureView top     = new FeatureView(w.locations[3], cs.locations[3]);
            FeatureView pants   = new FeatureView(w.locations[4], cs.locations[4]);
            FeatureView shoes   = new FeatureView(w.locations[5], cs.locations[5]);

            clothes.features.Add(top);
            clothes.features.Add(pants);
            clothes.features.Add(shoes);
            t.Add(clothes);

            return(t);
        }