public void DetectAll() { if (_DK_UMACrowd == null) { UMACrowdObj = GameObject.Find("DKUMACrowd"); if (UMACrowdObj == null) { UMACrowdObj = (GameObject)Instantiate(Resources.Load("DKUMACrowd"), Vector3.zero, Quaternion.identity); UMACrowdObj.name = "DKUMACrowd"; #if UNITY_EDITOR PrefabUtility.ReconnectToLastPrefab(UMACrowdObj); #endif } _DK_UMACrowd = UMACrowdObj.GetComponent <DK_UMACrowd>(); } if (!DKumaGenerator) { DKumaGenerator = GameObject.Find("DKUMAGenerator").GetComponent("DKUMAGenerator") as DKUMAGenerator; } if (!slotLibrary) { slotLibrary = _DK_UMACrowd.slotLibrary; } if (!raceLibrary) { raceLibrary = _DK_UMACrowd.raceLibrary; } if (!overlayLibrary) { overlayLibrary = _DK_UMACrowd.overlayLibrary; } }
public void Prepare(DKUMAData _umaData, DK_RPG_SelfGenerator _umaGenerator) { umaData = _umaData; umaGenerator = _umaGenerator; _DKumaGenerator = GameObject.Find("DKUMAGenerator").GetComponent <DKUMAGenerator>(); EditorStart(); }
protected override void Start() { _DKumaGenerator = GameObject.Find("DKUMAGenerator").GetComponent <DKUMAGenerator>(); // umaGenerator.umaData.cleanTextures(); materialDefinitionList = new List <DKUMAData.MaterialDefinition>(); //Update atlas area can be handled here DKUMAData.MaterialDefinition tempMaterialDefinition = new DKUMAData.MaterialDefinition(); DKSlotData[] slots = umaGenerator.umaData.umaRecipe.slotDataList; if (slots == null) { Debug.LogError(umaGenerator.umaData.gameObject.name + " can not be generated : the Slot list is umpty. Verify your Elements configuration."); } else if (slots.Length > 0) { for (int i = 0; i < slots.Length; i++) { if (slots[i] != null && slots[i].overlayList.Count != 0) { tempMaterialDefinition = new DKUMAData.MaterialDefinition(); tempMaterialDefinition.baseTexture = slots[i].overlayList[0].textureList; tempMaterialDefinition.baseColor = slots[i].overlayList[0].color; tempMaterialDefinition.materialSample = slots[i].materialSample; tempMaterialDefinition.overlays = new DKUMAData.textureData[slots[i].overlayList.Count - 1]; tempMaterialDefinition.overlayColors = new Color32[tempMaterialDefinition.overlays.Length]; tempMaterialDefinition.rects = new Rect[tempMaterialDefinition.overlays.Length]; tempMaterialDefinition.channelMask = new Color32[tempMaterialDefinition.overlays.Length + 1][]; tempMaterialDefinition.channelAdditiveMask = new Color32[tempMaterialDefinition.overlays.Length + 1][]; tempMaterialDefinition.channelMask[0] = slots[i].overlayList[0].channelMask; tempMaterialDefinition.channelAdditiveMask[0] = slots[i].overlayList[0].channelAdditiveMask; tempMaterialDefinition.slotData = slots[i]; for (int overlayID = 0; overlayID < slots[i].overlayList.Count - 1; overlayID++) { tempMaterialDefinition.overlays[overlayID] = new DKUMAData.textureData(); tempMaterialDefinition.rects[overlayID] = slots[i].overlayList[overlayID + 1].rect; tempMaterialDefinition.overlays[overlayID].textureList = slots[i].overlayList[overlayID + 1].textureList; tempMaterialDefinition.overlayColors[overlayID] = slots[i].overlayList[overlayID + 1].color; tempMaterialDefinition.channelMask[overlayID + 1] = slots[i].overlayList[overlayID + 1].channelMask; tempMaterialDefinition.channelAdditiveMask[overlayID + 1] = slots[i].overlayList[overlayID + 1].channelAdditiveMask; } materialDefinitionList.Add(tempMaterialDefinition); } } } if (_DKumaGenerator.usePRO && UnityEditorInternal.InternalEditorUtility.HasPro()) { textureProcessPROCoroutine = new DK_RPG_TextureProcessPROCoroutine(); } else { textureProcessIndieCoroutine = new DK_RPG_TextureProcessIndieCoroutine(); } packTexture = new MaxRectsBinPack(_DKumaGenerator.atlasResolution, _DKumaGenerator.atlasResolution, false); }
/* * public void OnEnable () { * DK_UMACrowdObj = GameObject.Find("UMACrowd"); * _DK_UMACrowd = DK_UMACrowdObj.gameObject.GetComponent< DK_UMACrowd >(); * _DK_UMACrowd.generateUMA = false; * _DK_UMACrowd.generateLotsUMA = false; * _DK_UMACrowd.UMAGenerated = true; * umaDirtyList.Clear(); * } */ public void Awake() { _DKUMAGenerator = GameObject.Find("DKUMAGenerator").GetComponent <DKUMAGenerator>(); DK_UMACrowdObj = GameObject.Find("DKUMACrowd"); if (DK_UMACrowdObj) { _DK_UMACrowd = DK_UMACrowdObj.gameObject.GetComponent <DK_UMACrowd>(); } #if UNITY_EDITOR if (_DKUMAGenerator.usePRO && !UnityEditorInternal.InternalEditorUtility.HasPro()) { // Debug.LogWarning("You might need to disable usePRO option in the Setup tab of DK UMA Editor window."); _DKUMAGenerator.usePRO = false; } else { _DKUMAGenerator.usePRO = true; } #endif List <string> tmplist = new List <string>(); tmplist.Add("_MainTex"); tmplist.Add("_BumpTex"); textureNameList = tmplist.ToArray(); // _DK_UMACrowd.generateUMA = false; // _DK_UMACrowd.generateLotsUMA = false; // _DK_UMACrowd.UMAGenerated = true; // umaDirtyList.Clear(); _DKUMAGenerator.maxMeshUpdates = 1; if (_DKUMAGenerator.atlasResolution == 0) { _DKUMAGenerator.atlasResolution = 256; } umaGeneratorCoroutine = new DK_RPG_SelfGeneratorCoroutine(); // if(!textureMerge){ // textureMerge = GameObject.Find ("TextureMerge").GetComponent("DKTextureMerge") as DKTextureMerge; if (!textureMerge) { Transform tempTextureMerger = Instantiate(_DKUMAGenerator.textureMergePrefab, Vector3.zero, Quaternion.identity) as Transform; tempTextureMerger.name = "TextureMerge"; textureMerge = tempTextureMerger.GetComponent("DKTextureMerge") as DKTextureMerge; textureMerge.transform.parent = transform; textureMerge.gameObject.SetActive(false); } // } //Garbage Collection hack var mb = (System.GC.GetTotalMemory(false) / (1024 * 1024)); if (mb < 10) { byte[] data = new byte[10 * 1024 * 1024]; data[0] = 0; data[10 * 1024 * 1024 - 1] = 0; } }
/* public void AutoLoadSelf (){ * DKUMASaveTool umaSaveTool = this; * GameObject gameObject = (GameObject)umaSaveTool.gameObject; * DKUMAData umaData = gameObject.GetComponent("DKUMAData") as DKUMAData; * umaData.Loading = true; * * DKUMAData.UMARecipe umaRecipe = new DKUMAData.UMARecipe(); * DKUMAData.UMAPackRecipe umaPackRecipe = new DKUMAData.UMAPackRecipe(); * * // streamedUMA = System.IO.File.ReadAllText(path); * streamedUMA = umaData.streamedUMA; * * umaPackRecipe = JsonMapper.ToObject<DKUMAData.UMAPackRecipe>(streamedUMA); * * * // foreach ( DKRaceData _Race in umaData.raceLibrary.raceElementList ){ * // if ( _Race.raceName == umaPackRecipe.race ) * // umaRecipe.raceData = _Race; * // } * * * umaRecipe.raceData = umaData.umaRecipe.raceData; * * // New * Transform tempUMA = (Instantiate(umaRecipe.raceData.racePrefab ,umaData.transform.position,umaData.transform.rotation) as GameObject).transform; * Debug.Log ( "Creating ... " +tempUMA ); * DKUMAData newUMA = tempUMA.gameObject.GetComponentInChildren<DKUMAData>(); * newUMA.umaRecipe = umaRecipe; * newUMA.streamedUMA = streamedUMA; * DKUMADnaHumanoid _UMADnaHumanoid = new DKUMADnaHumanoid(); * Dictionary<Type,DKUMADna> umaDna = new Dictionary<Type,DKUMADna>(); * * newUMA.umaPackRecipe = umaPackRecipe; * * // DNA * // load DK_UMAdnaHumanoid * newUMA.umaRecipe.umaDna.Clear(); * for(int dna = 0; dna < newUMA.umaPackRecipe.packedDna.Count; dna++){ * Type dnaType = DKUMADna.GetType(newUMA.umaPackRecipe.packedDna[dna].dnaType); * newUMA.umaRecipe.umaDna.Add(dnaType, DKUMADna.LoadInstance(dnaType, umaPackRecipe.packedDna[dna].packedDna)); * umaDna = newUMA.umaRecipe.umaDna; * * } * * // Modifyers * for (int i = 0; i < umaRecipe.raceData.DNAConverterDataList.Count; i ++) { * // create new DK DNA * DKRaceData.DNAConverterData _newDNA = new DKRaceData.DNAConverterData(); * * // add to DK_UMAdnaHumanoid * DKUMADna temp = null; * if ( umaDna.TryGetValue(_UMADnaHumanoid.GetType(), out temp) ){ * Debug.Log ( "success : " +umaDna[_UMADnaHumanoid.GetType()].Values.GetValue(i).ToString() ); * * // there it is, apply the value to the modifyer * DNAValue = float.Parse( umaDna[_UMADnaHumanoid.GetType()].Values.GetValue(i).ToString() ); * } * * _newDNA.Name = umaRecipe.raceData.DNAConverterDataList[i].Name; * _newDNA.Value = DNAValue; * _newDNA.Part = umaRecipe.raceData.DNAConverterDataList[i].Part; * _newDNA.Part2 = umaRecipe.raceData.DNAConverterDataList[i].Part2; * newUMA.DNAList2.Add(_newDNA); * * } * newUMA.LoadFromMemoryStream(); * newUMA.Awaking(); * newUMA.atlasResolutionScale = umaData.atlasResolutionScale; * newUMA.Dirty(true, true, true); * newUMA.transform.parent.gameObject.name = umaData.transform.parent.name; * newUMA.transform.parent = umaData.transform.parent ; * * // serializedObject.ApplyModifiedProperties(); * * // Finshing by destroying the previous model #if UNITY_EDITOR * // DestroyImmediate(umaData.transform.gameObject); #endif * // if ( Application.isPlaying ) Destroy(umaData.transform.gameObject); * * } */ #region Old AutoLoadSelf () public void AutoLoadSelf() { GameObject DKUMAGeneratorObj = GameObject.Find("DKUMAGenerator"); if (DKUMAGeneratorObj != null) { _DKUMAGenerator = DKUMAGeneratorObj.GetComponent <DKUMAGenerator>(); } DKUMAData umaData = gameObject.GetComponent("DKUMAData") as DKUMAData; if (umaData.transform.parent && umaData.transform.parent.name.Contains("(Clone)") == false) { umaData.Loading = true; if (umaData) { umaData.LoadFromMemoryStream(); for (int i = 0; i < _DKUMAGenerator.umaDirtyList.Count; i++) { if (_DKUMAGenerator.umaDirtyList[i] == null) { _DKUMAGenerator.umaDirtyList.Remove(_DKUMAGenerator.umaDirtyList[i]); } } _DKUMAGenerator.Awake(); umaData.dirty = false; umaData.Dirty(true, true, true); umaData.myRenderer.enabled = false; // Debug.Log ( "AutoLoadSelf"); } } }
public void Prepare(DKUMAGenerator _umaGenerator) { umaGenerator = _umaGenerator; }
public void Prepare(DKUMAData _umaData, DKUMAGenerator _umaGenerator) { umaData = _umaData; umaGenerator = _umaGenerator; }