示例#1
0
 /// <summary>
 /// 启动 Unity3d IDE 时初始化
 /// </summary>
 static Git()
 {
     ExecutablePath = EditorPrefs.GetString(kGitExecutablePath, "git");
     CheckEnvironment();
 }
示例#2
0
 /// <summary>
 /// Gets the user-preference to auto-show the demo build on success.
 /// </summary>
 /// <param name="isEnabled"></param>
 internal static bool IsAutoShowBuildOnSuccessEnabled()
 {
     return(EditorPrefs.GetBool(WearableEditorConstants.SHOW_BUILD_ON_SUCCESS_KEY,
                                WearableEditorConstants.DEFAULT_SHOW_BUILD_ON_SUCCESS_PREF));
 }
示例#3
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        CheckInitialize(property, label);

        position.height = 17f;

        var foldoutRect = position;

        foldoutRect.width -= 2 * kButtonWidth;
        EditorGUI.BeginChangeCheck();
        _Foldout = EditorGUI.Foldout(foldoutRect, _Foldout, label, true);
        if (EditorGUI.EndChangeCheck())
        {
            EditorPrefs.SetBool(label.text, _Foldout);
        }

        var buttonRect = position;

        buttonRect.x     = position.width - kButtonWidth + position.x;
        buttonRect.width = kButtonWidth + 2;

        if (GUI.Button(buttonRect, new GUIContent("+", "Add item"), EditorStyles.miniButton))
        {
            AddNewItem();
        }

        buttonRect.x -= kButtonWidth;

        if (GUI.Button(buttonRect, new GUIContent("X", "Clear dictionary"), EditorStyles.miniButtonRight))
        {
            ClearDictionary();
        }

        if (!_Foldout)
        {
            return;
        }

        foreach (var item in _WList.dictionary)
        {
            var key   = item.Key;
            var value = item.Value;

            position.y += 17f;

            var keyRect = position;
            keyRect.width /= 2;
            keyRect.width -= 4;
            EditorGUI.BeginChangeCheck();
            var newKey = DoField(keyRect, typeof(T), key);
            if (EditorGUI.EndChangeCheck())
            {
                try
                {
                    _WList.dictionary.Remove(key);
                    _WList.dictionary.Add(newKey, value);
                }
                catch (Exception e)
                {
                    Debug.Log(e.Message);
                }
                break;
            }

            var valueRect = position;
            valueRect.x     = position.width / 2 + 15;
            valueRect.width = keyRect.width - kButtonWidth;
            EditorGUI.BeginChangeCheck();
            value = DoField(valueRect, typeof(int), value);
            if (EditorGUI.EndChangeCheck())
            {
                _WList.dictionary[key] = value;
                break;
            }

            var removeRect = valueRect;
            removeRect.x     = valueRect.xMax + 2;
            removeRect.width = kButtonWidth;
            if (GUI.Button(removeRect, new GUIContent("x", "Remove item"), EditorStyles.miniButtonRight))
            {
                RemoveItem(key);
                break;
            }
        }
    }
示例#4
0
 public void Set(bool value)
 {
     this.value = value;
     EditorPrefs.SetBool(name, value);
 }
 private void SetStep(int index)
 {
     EditorPrefs.SetInt("ME.ECS.QuickStart.Step", index);
 }
示例#6
0
	// -------------------------------------------------------------------------------------------
	void winActionToolbar(int id)
	{
		Rect		popupRect	= FXMakerLayout.GetActionToolbarRect();
		Rect		baseRect;
		Rect		rect;
		string		info		= "";
		string		infotooltip	= "";
		int			nColCount	= 10;
		int			nRowCount	= 5;
		GUIContent	content;

		// window desc -----------------------------------------------------------
		FXMakerTooltip.WindowDescription(popupRect, FXMakerLayout.WINDOWID.EFFECT_CONTROLS, null);

		// mini ----------------------------------------------------------------
		m_bMinimize = GUI.Toggle(new Rect(3, 1, FXMakerLayout.m_fMinimizeClickWidth, FXMakerLayout.m_fMinimizeClickHeight), m_bMinimize, "Mini");
		if (GUI.changed)
			EditorPrefs.SetBool("FXMakerControls.m_bMinimize", m_bMinimize);
		GUI.changed = false;
		if (FXMakerLayout.m_bMinimizeAll || m_bMinimize)
		{
			FXMakerLayout.m_fActionToolbarHeight = FXMakerLayout.m_MinimizeHeight;

			nRowCount = 1;
			// mesh info -----------------------------------------------------------------
			baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
			if (FXMakerMain.inst.IsCurrentEffectObject())
			{
				info		= string.Format("P={0} M={1} T={2}", m_nParticleCount, m_nMeshCount, m_nTriangles);
				infotooltip	= string.Format("ParticleCount = {0} MeshCount = {1}\n Mesh: Triangles = {2} Vertices = {3}", m_nParticleCount, m_nMeshCount, m_nTriangles, m_nVertices);
			}
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), new GUIContent(info, FXMakerTooltip.Tooltip(infotooltip)));

			// CurrentTime Horizontal Slider ----------------------------------------------
			if (FXMakerMain.inst.IsCurrentEffectObject())
			{
				float fMaxTime = (m_nRepeatIndex <= m_nPlayIndex) ? m_fPlayToolbarTimes[m_nPlayIndex] : 10.0f;
				baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
				content  = FXMakerTooltip.GetHcEffectControls("ElapsedTime", "");
				content.text += " " + (Time.time - m_fPlayStartTime).ToString("0.000");
				GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 2), content);
				rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 4, 4);
				rect.y += 5;
				GUI.HorizontalSlider(rect, Time.time - m_fPlayStartTime, 0.0f, fMaxTime);

				// restart
				baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
				if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 8, 2), FXMakerTooltip.GetHcEffectControls("Restart", "")))
					CreateInstanceEffect();
			}

			FXMakerMain.inst.SaveTooltip();
			return;
		} else FXMakerLayout.m_fActionToolbarHeight = FXMakerLayout.m_fOriActionToolbarHeight;

		// mesh info -----------------------------------------------------------------
		baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 2);
		if (NcEffectBehaviour.GetRootInstanceEffect())
		{
			info		= string.Format("P = {0}\nM = {1}\nT = {2}", m_nParticleCount, m_nMeshCount, m_nTriangles);
			infotooltip	= string.Format("ParticleCount = {0} MeshCount = {1}\n Mesh: Triangles = {2} Vertices = {3}", m_nParticleCount, m_nMeshCount, m_nTriangles, m_nVertices);
		}
		GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 1), new GUIContent(info, FXMakerTooltip.Tooltip(infotooltip)));

		// control button ------------------------------------------------------------
		if (FXMakerMain.inst.IsCurrentEffectObject())
		{
			bool bClick = false;

			// Play ---------------------------------------
			GUIContent[]	playToolbarContents	= FXMakerTooltip.GetHcEffectControls_Play(0, m_fTimeScale, m_fPlayToolbarTimes[1], m_fPlayToolbarTimes[m_nRepeatIndex], m_fPlayToolbarTimes[m_nRepeatIndex+1], m_fPlayToolbarTimes[m_nRepeatIndex+2], m_fPlayToolbarTimes[m_nRepeatIndex+3], m_fPlayToolbarTimes[m_nRepeatIndex+4]);
			baseRect		= FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 1, 1), FXMakerTooltip.GetHcEffectControls("Play", ""));
//			int nPlayIndex	= GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 8), m_nPlayIndex, playToolbarContents, playToolbarContents.Length);
			int nPlayIndex	= FXMakerLayout.TooltipSelectionGrid(popupRect, FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 8), m_nPlayIndex, playToolbarContents, playToolbarContents.Length);

			if (GUI.changed)
				bClick = true;

			// Trans ---------------------------------------
			GUIContent[]	TransToolbarContents	= FXMakerTooltip.GetHcEffectControls_Trans(m_nTransAxis);
			baseRect		= FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 1, 1);
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 1, 1), FXMakerTooltip.GetHcEffectControls("Trans", ""));
//			int nTransIndex	= GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 8), m_nTransIndex, TransToolbarContents, TransToolbarContents.Length);
			int nTransIndex	= FXMakerLayout.TooltipSelectionGrid(popupRect, FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 8), m_nTransIndex, TransToolbarContents, TransToolbarContents.Length);

			if (GUI.changed)
			{
				bClick = true;
				m_fTransRate = 1.0f;
				if ((nTransIndex == 1 || nTransIndex == 2) && Input.GetMouseButtonUp(1))	// m_nTransIndex scale
				{
					if (m_nTransAxis == NgEnum.AXIS.Z)
						m_nTransAxis = 0;
					else m_nTransAxis++;
					UnityEditor.EditorPrefs.SetInt("FXMakerControls.m_nTransAxis", (int)m_nTransAxis);
				}
			}

			if (bClick)
			{
				FXMakerMain.inst.CreateCurrentInstanceEffect(false);
				RunActionControl(nPlayIndex, nTransIndex);
				UnityEditor.EditorPrefs.SetInt("FXMakerControls.m_nPlayIndex", m_nPlayIndex);
				UnityEditor.EditorPrefs.SetInt("FXMakerControls.m_nTransIndex", m_nTransIndex);
			}
		}

		// TransSpeed Horizontal Slider -----------------------------------------------
		float	TransSpeed	= m_fDistPerTime;
		baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 2, 1);
		content  = FXMakerTooltip.GetHcEffectControls("DistPerTime", "");
		content.text += " " + m_fDistPerTime.ToString("00.00");
		GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), content);
		rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 5);
		rect.y += 5;
		TransSpeed = GUI.HorizontalSlider(rect, TransSpeed, 0.1f, 40.0f);
		// TransSpeed Trans ----------------------------------------------
// 		if (GUI.Button(NgLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 23, 1), NgTooltip.GetHcEffectControls("1", "")))
// 			TransSpeed = 1;
		if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 14, 1), FXMakerTooltip.GetHcEffectControls("<", "")))
			TransSpeed = (int)(TransSpeed-1);
		if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 15, 1), FXMakerTooltip.GetHcEffectControls(">", "")))
			TransSpeed = (int)(TransSpeed+1);
		if (TransSpeed != m_fDistPerTime)
		{
			m_fDistPerTime = (TransSpeed == 0 ? 0.1f : TransSpeed);
			UnityEditor.EditorPrefs.SetFloat("FXMakerControls.m_fDistPerTime", m_fDistPerTime);
			// Trans 상태면.. 바로 적용
			if (0 < m_nTransIndex)
				CreateInstanceEffect();
		}

		if (NgLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 9, 1), FXMakerTooltip.GetHcEffectControls("Multi", m_nMultiShotCount.ToString()), true))
		{
			if (Input.GetMouseButtonUp(0))
			{
				m_nMultiShotCount++;
				if (4 < m_nMultiShotCount)
					m_nMultiShotCount = 1;
			} else {
				m_nMultiShotCount = 1;
			}
			CreateInstanceEffect();
		}

		// front Rotation ----------------------------------------------
		GUIContent[]		rotateToolbarContents	= FXMakerTooltip.GetHcEffectControls_Rotate();
		baseRect			= FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 2, 1);
//		int nRotateIndex	= GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 8, 1), m_nRotateIndex, rotateToolbarContents, rotateToolbarContents.Length);
		int nRotateIndex	= FXMakerLayout.TooltipSelectionGrid(popupRect, FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 8, 1), m_nRotateIndex, rotateToolbarContents, rotateToolbarContents.Length);
		if (nRotateIndex != m_nRotateIndex)
		{
			m_nRotateIndex = nRotateIndex;
			UnityEditor.EditorPrefs.SetInt("FXMakerControls.m_nRotateIndex", m_nRotateIndex);
			// Trans 상태면.. 바로 적용
			if (0 < m_nTransIndex)
				CreateInstanceEffect();
		}

		// timeScale Horizontal Slider -----------------------------------------------
		float timeScale = m_fTimeScale;
		baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 3, 1);
		content  = FXMakerTooltip.GetHcEffectControls("TimeScale", "");
		content.text += " " + m_fTimeScale.ToString("0.00");
		GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), content);
		rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 5);
		rect.y += 5;
		timeScale = GUI.HorizontalSlider(rect, timeScale, 0.0f, 2.0f);
		if (timeScale == 0)
		{
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 7, 1), FXMakerTooltip.GetHcEffectControls("Resume", "")))
				timeScale = m_fOldTimeScale;
		} else {
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 7, 1), FXMakerTooltip.GetHcEffectControls("Pause", "")))
				timeScale = 0;
		}
		if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 8, 1), FXMakerTooltip.GetHcEffectControls("Reset", "")))
			timeScale = 1;
		SetTimeScale(timeScale);

		// CurrentTime Horizontal Slider ----------------------------------------------
		if (FXMakerMain.inst.IsCurrentEffectObject())
		{
			float fMaxTime = (m_nRepeatIndex <= m_nPlayIndex) ? m_fPlayToolbarTimes[m_nPlayIndex] : 10.0f;
			baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 4, 1);
			content  = FXMakerTooltip.GetHcEffectControls("ElapsedTime", "");
			content.text += " " + (Time.time - m_fPlayStartTime).ToString("0.000");
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), content);
			rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 5);
			rect.y += 5;
			GUI.HorizontalSlider(rect, Time.time - m_fPlayStartTime, 0.0f, fMaxTime);
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 14, 1), FXMakerTooltip.GetHcEffectControls("+.5", "")))
			{
				SetTimeScale(1.0f);
				Invoke("invokeStopTimer", 0.5f);
			}
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 15, 1), FXMakerTooltip.GetHcEffectControls("+.1", "")))
			{
				SetTimeScale(0.4f);
				Invoke("invokeStopTimer", 0.1f);
			}
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 16, 1), FXMakerTooltip.GetHcEffectControls("+.05", "")))
			{
				SetTimeScale(0.2f);
				Invoke("invokeStopTimer", 0.05f);
			}
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 17, 1), FXMakerTooltip.GetHcEffectControls("+.01", "")))
			{
				SetTimeScale(0.04f);
				Invoke("invokeStopTimer", 0.01f);
			}

			// restart
			baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 3, 2);
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 9, 1), FXMakerTooltip.GetHcEffectControls("Restart", "")))
				CreateInstanceEffect();
		}
		FXMakerMain.inst.SaveTooltip();
	}
示例#7
0
        /// <summary>
        /// The ReordableList remove button has been pressed. Remove the selected state.
        /// </summary>
        private void OnImpactAnimatorAudioStateSetStateListRemove(ReorderableList list)
        {
            var animatorAudioState = m_Shield.ImpactAnimatorAudioStateSet.States[EditorPrefs.GetInt(SelectedImpactAnimatorAudioStateSetIndexKey)];
            var states             = StateInspector.OnStateListRemove(animatorAudioState.States, GetSelectedImpactAnimatorAudioStateSetStateIndexKey(EditorPrefs.GetInt(SelectedImpactAnimatorAudioStateSetIndexKey)), list);

            if (animatorAudioState.States.Length != states.Length)
            {
                InspectorUtility.SynchronizePropertyCount(states, m_ReorderableImpactAnimatorAudioStateSetStateList.serializedProperty);
                InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
                animatorAudioState.States = states;
            }
        }
示例#8
0
 public static void SaveCloseStatus()
 {
     EditorPrefs.SetBool(KEY_EDITOR_PREF_SAVE_LAST_SELECTION_CLOSED, _displayInside == null);
 }
示例#9
0
 public static bool WasOpenLastTimeWeCloseUnity()
 {
     return(EditorPrefs.GetBool(KEY_EDITOR_PREF_SAVE_LAST_SELECTION_CLOSED));
 }
 void Awake()
 {
     EditorPrefs.SetString("CinemaProCamsVersion", version);
 }
        void OnInspectorGUI(DeterministicSessionConfigAsset asset)
        {
            EditorGUI.BeginChangeCheck();

            EditorPrefs.SetBool(PREFS_KEY, EditorGUILayout.Toggle("Show Help Info", EditorPrefs.GetBool(PREFS_KEY, true)));
            HelpBox("Should we show these help boxes?");

            GUILayout.Label("Simulation", EditorStyles.boldLabel);

            asset.Config.UpdateFPS = Math.Max(1, EditorGUILayout.IntField("Simulation Rate", asset.Config.UpdateFPS));
            HelpBox("How many ticks per second Quantum should execute.");

            asset.Config.LockstepSimulation = EditorGUILayout.Toggle("Lockstep", asset.Config.LockstepSimulation);
            HelpBox("Runs the quantum simulation in lockstep mode, where no rollbacks are performed. It's recommended to set input 'Static Delay' to at least 10 and 'Send Rate' to 1.");

            asset.Config.RunInBackgroundThread = EditorGUILayout.Toggle("Run In Background Thread", asset.Config.RunInBackgroundThread);
            WarnBox("!EXPERIMENTAL! Runs the quantum simulation in a background thread, NOT usable in lockstep mode.");

            EditorGUI.BeginDisabledGroup(asset.Config.RunInBackgroundThread == false);
            asset.Config.BackgroundThreadPriority = (System.Threading.ThreadPriority)EditorGUILayout.EnumPopup("Background Thread Priority", asset.Config.BackgroundThreadPriority);
            HelpBox("Which thread priority the background thread should run at.");
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(asset.Config.LockstepSimulation);

            if (asset.Config.LockstepSimulation)
            {
                asset.Config.RollbackWindow = asset.Config.UpdateFPS;
            }

            asset.Config.RollbackWindow = Math.Max(asset.Config.UpdateFPS, EditorGUILayout.IntField("Rollback Window", asset.Config.RollbackWindow));
            HelpBox("How many frames are kept in the local ring buffer on each client. Controls how much Quantum can predict into the future. Not used in lockstep mode.");


            EditorGUI.BeginDisabledGroup(asset.Config.ExposeVerifiedStatusInsideSimulation);
            asset.Config.SkipRollbackWhenPossible = EditorGUILayout.Toggle("Skip Rollbacks When Possible", asset.Config.SkipRollbackWhenPossible);
            HelpBox("If Quantum should skip performing rollbacks and re-predict when it's not needed to retain determinism. Not used in lockstep mode. Mutually exclusive with the 'Expose Verified Status In Simulation' setting.");
            EditorGUI.EndDisabledGroup();

            if (asset.Config.SkipRollbackWhenPossible)
            {
                asset.Config.ExposeVerifiedStatusInsideSimulation = false;
            }

            asset.Config.SkipFrameBufferIntegrityChecks = EditorGUILayout.Toggle("Skip Frame Buffer Integrity Checks", asset.Config.SkipFrameBufferIntegrityChecks);
            HelpBox("If Quantum should skip performing integrity checks on its internal frame buffer (useful during development, enable skipping for release). Not used in lockstep mode.");

            EditorGUI.BeginDisabledGroup(asset.Config.SkipRollbackWhenPossible);
            asset.Config.ExposeVerifiedStatusInsideSimulation = EditorGUILayout.Toggle("Expose Verified Status In Simulation", asset.Config.ExposeVerifiedStatusInsideSimulation);
            WarnBox("!EXPERIMENTAL! Exposes the real verified status of a frame inside of the simulation. Mutually exclusive with the 'Skip Rollbacks When Possible' setting.");
            EditorGUI.EndDisabledGroup();

            if (asset.Config.ExposeVerifiedStatusInsideSimulation)
            {
                asset.Config.SkipRollbackWhenPossible = false;
            }

            EditorGUI.EndDisabledGroup();

            asset.Config.ChecksumInterval = Math.Max(0, EditorGUILayout.IntField("Checksum Interval", asset.Config.ChecksumInterval));
            HelpBox("How often we should send checksums of the frame state to the server for verification (useful during development, set to zero for release). Defined in frames.");

            GUILayout.Label("Input", EditorStyles.boldLabel);

            asset.Config.AggressiveSendMode = EditorGUILayout.Toggle("Aggressive Send", asset.Config.AggressiveSendMode);
            HelpBox("If the server should skip buffering and perform aggressive input sends, only suitable for games with <= 4 players.");

            asset.Config.InputDelay = Math.Max(0, EditorGUILayout.IntField("Static Delay", asset.Config.InputDelay));
            HelpBox("How much input delay that always is applied to local player input. Defined in frames.");

            asset.Config.InputPacking = Math.Max(1, EditorGUILayout.IntField("Send Rate", asset.Config.InputPacking));
            HelpBox("How often Quantum sends input to the server. 1 = Every frame, 2 = Every other frame, etc.");

            asset.Config.InputRedundancyStagger = Math.Max(0, EditorGUILayout.IntField("Send Staggering", asset.Config.InputRedundancyStagger));
            HelpBox("How much staggering the Quantum client should apply to redundant input resends. 1 = Wait one frame, 2 = Wait two frames, etc.");

            asset.Config.InputRepeatMaxDistance = Math.Max(0, EditorGUILayout.IntField("Repeat Max Distance", asset.Config.InputRepeatMaxDistance));
            HelpBox("How many frames Quantum will scan for repeatable inputs. 5 = Scan five frames forward and backwards, 10 = Scan ten frames, etc.");

            EditorGUI.BeginDisabledGroup(asset.Config.AggressiveSendMode);
            asset.Config.InputSoftTolerance = Math.Max(0, EditorGUILayout.IntField("Soft Tolerance", asset.Config.InputSoftTolerance));
            HelpBox("How many frames the server will wait until it will pre-emptively send any received inputs for a frame. Not used when 'Aggresive Send' is enabled.");
            EditorGUI.EndDisabledGroup();

            asset.Config.InputHardTolerance = Math.Max(-10, EditorGUILayout.IntField("Hard Tolerance", asset.Config.InputHardTolerance));
            HelpBox("How many frames the server will wait until it expires a frame and replaces all non-received inputs with repeated inputs or null's and sends it out to all players.");

            asset.Config.MinOffsetCorrectionDiff = Math.Max(1, EditorGUILayout.IntField("Offset Correction Limit", asset.Config.MinOffsetCorrectionDiff));
            HelpBox("How many frames the current local input delay must diff to the current requested offset for Quantum to update the local input offset. Defined in frames.");

            asset.Config.RttBias = Mathf.Clamp(EditorGUILayout.FloatField("Offset RTT Bias", asset.Config.RttBias), 0.5f, 1.0f);
            HelpBox("The multiplier used by the Quantum simulator when calculating your a players dynamic input offset. Defined as a multiplier.");

            GUILayout.Label("Time", EditorStyles.boldLabel);

            asset.Config.TimeCorrectionRate = Math.Max(0, EditorGUILayout.IntField("Correction Send Rate", asset.Config.TimeCorrectionRate));
            HelpBox("How many times per second the server will send out time correction packages to make sure every clients time is synchronized.");

            asset.Config.MinTimeCorrectionFrames = Math.Max(0, EditorGUILayout.IntField("Correction Frames Limit", asset.Config.MinTimeCorrectionFrames));
            HelpBox("How much the local client time must differ with the server time when a time correction package is received for the client to adjust it's local clock. Defined in frames.");

            asset.Config.TimeScaleMin = Mathf.Clamp(EditorGUILayout.IntField("Time Scale Minimum (%)", asset.Config.TimeScaleMin), 10, 100);
            HelpBox("The smallest timescale that can be applied by the server. Defined in percent.");

            asset.Config.TimeScalePingMin = Mathf.Clamp(EditorGUILayout.IntField("Time Scale Ping Start (ms)", asset.Config.TimeScalePingMin), 0, 1000);
            HelpBox("The ping value that the server will start lowering the time scale towards 'Time Scale Minimum'. Defined in milliseconds.");

            asset.Config.TimeScalePingMax = Mathf.Clamp(EditorGUILayout.IntField("Time Scale Ping End (ms)", asset.Config.TimeScalePingMax), asset.Config.TimeScalePingMin + 1, 1000);
            HelpBox("The ping value that the server will reach the 'Time Scale Minimum' value at, i.e. be at its slowest setting. Defined in milliseconds.");

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(asset);
            }
        }
示例#12
0
 //call from Autorun
 public static void OpenPopupStartup()
 {
     showAtStartup = EditorPrefs.GetInt(PREFSHOWATSTARTUP, 1) == 1;
     OpenWelcomeWindow();
 }
示例#13
0
        public void OnGUI()
        {
            InitInterface();
            GUI.Box(new Rect(0, 0, width, 60), "", imgHeader);
            GUILayoutUtility.GetRect(position.width, 50);
            GUILayout.Space(30);

            GUILayout.BeginHorizontal();

            if (Button2(adsIcon))
            {
                Application.OpenURL(VERYSIMPLEAD_URL);
            }

            if (Button2(leaderboardIcon))
            {
                Application.OpenURL(VERYSIMPLELEADERBOARD_URL);
            }

            if (Button2(shareIcon))
            {
                Application.OpenURL(VERYSIMPLESHARE_URL);
            }

            if (Button2(gifIcon))
            {
                Application.OpenURL(VERYSIMPLEGIF_URL);
            }

            if (Button2(vsrateIcon))
            {
                Application.OpenURL(VERYSIMPLERATE_URL);
            }


//			if (Button(adsIcon,"WANT TO MONETIZE THIS ASSET?","Get 'Very Simple Ads' on the Asset Store and earn money in a minute!")){
//				Application.OpenURL(VERYSIMPLEAD_URL);
//			}
//
//			if (Button(leaderboardIcon,"WANT TO ADD A LEADERBOARD?","Get 'Very Simple Leaderboard' on the Asset Store!")){
//				Application.OpenURL(VERYSIMPLELEADERBOARD_URL);
//			}
//
//			if (Button(shareIcon,"WANT TO ADD A SOCIAL SHARING BUTTON TO SHARE LIVE GAME SCREENSHOTS?","Get 'Very Simple Share' on the Asset Store!")){
//				Application.OpenURL(VERYSIMPLESHARE_URL);
//			}
//
//			if (Button(gifIcon,"WANT TO RECORD AND SHARE ANIMATED GIF OF YOUR GAME?","Get 'Very Simple GIF' on the Asset Store!")){
//				Application.OpenURL(VERYSIMPLEGIF_URL);
//			}

            GUILayout.EndHorizontal();


            GUILayout.BeginVertical();
            if (Button(communityIcon, "Join the community and get access to direct download",
                       "Be informed of the latest updates."))
            {
                Application.OpenURL(COMMUNITY_URL);
            }

            if (Button(rateIcon, "Rate this asset", "Write us a review on the asset store."))
            {
                Application.OpenURL(RATEUS_URL);
            }

            if (Button(moreGamesIcon, "More Unity assets from us", "Have a look to our Unity's Asset Store catalog!"))
            {
                Application.OpenURL(APPADVISORY_UNITY_CATALOG_URL);
            }

            if (Button(facebookIcon, "Facebook page", "Follow us on Facebook."))
            {
                Application.OpenURL(FACEBOOK_URL);
            }

            if (Button(questionIcon, "A request?", "Don't hesitate to contact us."))
            {
                Application.OpenURL(REQUEST_URL);
            }

            if (Button(linkedinIcon, "My Linkedin", "For professional purpose only"))
            {
                Application.OpenURL(LINKEDIN_URL);
            }

            GUILayout.Space(3);

            bool show = GUILayout.Toggle(showAtStartup, "Show at startup");

            if (show != showAtStartup)
            {
                showAtStartup = show;
                int i = GetInt(showAtStartup);
                Debug.Log("toggle i = " + i);
                EditorPrefs.SetInt(PREFSHOWATSTARTUP, i);
            }

            GUILayout.EndVertical();
        }
示例#14
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            List <string> assetPathModified = new List <string>();

            foreach (var importedAsset in importedAssets)
            {
                PSDImporter importer = AssetImporter.GetAtPath(importedAsset) as PSDImporter;
                if (importer != null)
                {
                    var texture = AssetDatabase.LoadAssetAtPath <UnityEngine.Texture2D>(importedAsset);
                    var sprites = AssetDatabase.LoadAllAssetsAtPath(importedAsset).OfType <Sprite>().ToArray();
                    if (texture == null || sprites.Length == 0)
                    {
                        continue;
                    }

                    importer.InitSpriteEditorDataProvider();
                    var physicsOutlineDataProvider = importer.GetDataProvider <ISpritePhysicsOutlineDataProvider>();
                    var textureDataProvider = importer.GetDataProvider <ITextureDataProvider>();
                    int actualWidth = 0, actualHeight = 0;
                    textureDataProvider.GetTextureActualWidthAndHeight(out actualWidth, out actualHeight);
                    float definitionScaleW = (float)texture.width / actualWidth;
                    float definitionScaleH = (float)texture.height / actualHeight;
                    float definitionScale  = Mathf.Min(definitionScaleW, definitionScaleH);
                    var   dataChanged = false;
                    foreach (var sprite in sprites)
                    {
                        var guid          = sprite.GetSpriteID();
                        var outline       = physicsOutlineDataProvider.GetOutlines(guid);
                        var outlineOffset = sprite.rect.size / 2;
                        if (outline != null && outline.Count > 0)
                        {
                            var convertedOutline = new Vector2[outline.Count][];
                            for (int i = 0; i < outline.Count; ++i)
                            {
                                convertedOutline[i] = new Vector2[outline[i].Length];
                                for (int j = 0; j < outline[i].Length; ++j)
                                {
                                    convertedOutline[i][j] = outline[i][j] * definitionScale + outlineOffset;
                                }
                            }
                            sprite.OverridePhysicsShape(convertedOutline);
                            dataChanged = true;
                        }
                    }

                    if (dataChanged)
                    {
                        assetPathModified.Add(importedAsset);
                    }
                }
            }

            if (assetPathModified.Count > 0)
            {
                var originalValue = EditorPrefs.GetBool("VerifySavingAssets", false);
                EditorPrefs.SetBool("VerifySavingAssets", false);
                AssetDatabase.ForceReserializeAssets(assetPathModified, ForceReserializeAssetsOptions.ReserializeMetadata);
                EditorPrefs.SetBool("VerifySavingAssets", originalValue);
            }
        }
 public EditorVariableBool(string name, string labelName, bool defaultValue) : base(name, labelName, defaultValue)
 {
     m_value = EditorPrefs.GetBool(name, m_defaultValue);
 }
示例#16
0
    void OnGUI()
    {
        if (_depthsDirty)
        {
            _depths.Clear();
            _depthsDirty = false;
        }
        GUILayout.BeginVertical();
        mScroll = GUILayout.BeginScrollView(mScroll);

        GUI.backgroundColor = new Color32(30, 144, 255, 255);
        for (int i = 0; i < UIDrawCall.list.size; ++i)
        {
            UIDrawCall dc  = UIDrawCall.list[i];
            string     key = dc.keyName;


            Color32 backgroundColor;

            if (_activeColors.ContainsKey(dc.panel))
            {
                backgroundColor = _activeColors[dc.panel];
            }
            else
            {
                backgroundColor = _allColors[_activeColors.Count % _allColors.Length];

                _activeColors.Add(dc.panel, backgroundColor);
            }

            if (!dc.isActive)
            {
                backgroundColor = Color.red;
            }

            GUI.backgroundColor = backgroundColor;
            GUI.color           = Color.white;

            string name = "<b>" + key + " of " + UIDrawCall.list.size + " (" + dc.panel.name + ")</b>";
            if (!dc.isActive)
            {
                name = name + " <b>(HIDDEN)</b>";
            }
            bool shouldBeUnfolded = DrawHeader(name, key);
            if (!shouldBeUnfolded)
            {
                continue;
            }

            NGUIEditorTools.BeginContents();
            GUI.backgroundColor = Color.white;
            EditorGUILayout.ObjectField("Material", dc.baseMaterial, typeof(Material), false);

            GUILayout.BeginHorizontal();


            string panelKey = key + "panel";

            int currentPanelDepth = dc.panel.depth;
            int panelDepth        = currentPanelDepth;

            if (_depths.ContainsKey(panelKey))
            {
                panelDepth = _depths[panelKey];
            }


            GUILayout.Label("Panel depth", GUILayout.Width(80f));
            _depths[panelKey] = EditorGUILayout.IntField(panelDepth, GUILayout.Width(50f));



            var alignBefore = GUI.skin.button.alignment;
            GUI.skin.button.alignment = TextAnchor.MiddleLeft;
            if (GUILayout.Button("Select panel: <b>" + dc.panel.name + "</b>", new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.MinWidth(250f) }))
            {
                Selection.activeGameObject = dc.panel.gameObject;
            }
            GUI.skin.button.alignment = alignBefore;
            GUILayout.Space(18f);

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Hide draw call", GUILayout.Width(90f));

            bool draw = !EditorGUILayout.Toggle(!dc.isActive);

            if (dc.isActive != draw)
            {
                dc.isActive = draw;
                EditorUtility.SetDirty(dc.panel);
            }
            GUILayout.EndHorizontal();
            // Apply panel depth buttons

            if (panelDepth != currentPanelDepth)
            {
                GUILayout.BeginHorizontal();
                Color oldColor = GUI.backgroundColor;
                GUI.backgroundColor = new Color(0.4f, 1f, 0.4f);
                if (GUILayout.Button("Apply Depth to panel", GUILayout.Width(150f)))
                {
                    dc.panel.depth = panelDepth;
                    _depths.Clear();
                    _depthsDirty = true;
                    GUI.FocusControl(null);
                    EditorUtility.SetDirty(dc.panel);
                }
                GUI.backgroundColor = new Color(1f, 0.8f, 0.8f);

                if (GUILayout.Button("Reset Depth", GUILayout.Width(150f)))
                {
                    _depths[panelKey] = currentPanelDepth;
                    GUI.FocusControl(null);
                    EditorUtility.SetDirty(dc.panel);
                }
                GUI.backgroundColor = oldColor;
                GUILayout.EndHorizontal();
            }



            var depths = new List <List <UIWidget> >();

            int initial         = NGUITools.GetHierarchy(dc.panel.cachedGameObject).Length + 1;
            int masterListIndex = -1;
            int currentDepth    = int.MinValue;

            for (int b = 0; b < UIWidget.list.size; ++b)
            {
                UIWidget w     = UIWidget.list[b];
                int      depth = w.depth;
                if (currentDepth == int.MinValue || currentDepth != depth)
                {
                    currentDepth = depth;
                    masterListIndex++;
                    depths.Add(new List <UIWidget>());
                }

                if (w.drawCall == dc)
                {
                    depths[masterListIndex].Add(w);
                }
            }



            for (int d = 0; d < depths.Count; d++)
            {
                int widgetCount = depths[d].Count;
                if (widgetCount < 1)
                {
                    continue;
                }
                currentDepth = depths[d][0].depth;

                string foldoutTitle = widgetCount + " Widget" + (widgetCount == 1 ? "" : "s") + " - Depth: " + currentDepth.ToString();

                string depthKey = key + "depth" + currentDepth.ToString();

                bool wasFoldedOut = EditorPrefs.GetBool(depthKey, false);

                int massDepth = currentDepth;
                if (_depths.ContainsKey(depthKey))
                {
                    massDepth = _depths[depthKey];
                }


                GUILayout.BeginHorizontal();


                GUILayout.Label("Depth", GUILayout.Width(40f));
                _depths[depthKey] = EditorGUILayout.IntField(massDepth, GUILayout.Width(50f));

                bool foldedOut = false;
                foldedOut = DrawDepthCollapser("<b>" + foldoutTitle + "</b> - Click to " + (wasFoldedOut ? "collapse" : "expand"), depthKey, wasFoldedOut);

                GUILayout.EndHorizontal();

                if (massDepth != currentDepth)
                {
                    GUILayout.BeginHorizontal();
                    Color oldColor = GUI.backgroundColor;
                    GUI.backgroundColor = new Color(0.4f, 1f, 0.4f);
                    if (GUILayout.Button("Apply Depth to widgets", GUILayout.Width(150f)))
                    {
                        for (int iW = 0; iW < depths[d].Count; iW++)
                        {
                            depths[d][iW].depth = massDepth;
                        }
                        EditorPrefs.DeleteKey(depthKey);
                        //_depths.Clear();
                        _depthsDirty = true;
                        GUI.FocusControl(null);
                        EditorUtility.SetDirty(dc.panel);
                    }
                    GUI.backgroundColor = new Color(1f, 0.8f, 0.8f);

                    if (GUILayout.Button("Reset Depth", GUILayout.Width(150f)))
                    {
                        _depths[depthKey] = currentDepth;
                        GUI.FocusControl(null);
                        EditorUtility.SetDirty(dc.panel);
                    }
                    GUI.backgroundColor = oldColor;
                    GUILayout.EndHorizontal();
                }



                if (foldedOut)
                {
                    for (int iW = 0; iW < depths[d].Count; iW++)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10f);
                        alignBefore = GUI.skin.button.alignment;
                        GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                        if (GUILayout.Button(NGUITools.GetHierarchy(depths[d][iW].cachedGameObject).Remove(0, initial), GUILayout.ExpandWidth(false)))
                        {
                            Selection.activeGameObject = depths[d][iW].gameObject;
                        }
                        GUI.skin.button.alignment = alignBefore;

                        GUILayout.EndHorizontal();
                    }
                }
            }
            NGUIEditorTools.EndContents();
            GUI.color = Color.white;
        }
        GUI.backgroundColor = Color.white;
        GUILayout.EndScrollView();
        GUILayout.EndVertical();
    }
 public EditorVariableInt(string name, string labelName, int defaultValue) : base(name, labelName, defaultValue)
 {
     m_value = EditorPrefs.GetInt(name, m_defaultValue);
 }
示例#18
0
        /// <summary>
        /// Update Unity Editor Preferences
        static void UpdateUnityPreferences(bool enabled)
        {
            if (enabled)
            {
#if UNITY_EDITOR_OSX
                var newPath = "/Applications/Visual Studio Code.app";
#elif UNITY_EDITOR_WIN
                var newPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Code" + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "code.cmd";
#else
                var newPath = "/usr/local/bin/code";
#endif

                // App
                if (EditorPrefs.GetString("kScriptsDefaultApp") != newPath)
                {
                    EditorPrefs.SetString("VSCode_PreviousApp", EditorPrefs.GetString("kScriptsDefaultApp"));
                }
                EditorPrefs.SetString("kScriptsDefaultApp", newPath);

                // Arguments
                if (EditorPrefs.GetString("kScriptEditorArgs") != "-r -g \"$(File):$(Line)\"")
                {
                    EditorPrefs.SetString("VSCode_PreviousArgs", EditorPrefs.GetString("kScriptEditorArgs"));
                }

                EditorPrefs.SetString("kScriptEditorArgs", "-r -g \"$(File):$(Line)\"");
                EditorPrefs.SetString("kScriptEditorArgs" + newPath, "-r -g \"$(File):$(Line)\"");


                // MonoDevelop Solution
                if (EditorPrefs.GetBool("kMonoDevelopSolutionProperties", false))
                {
                    EditorPrefs.SetBool("VSCode_PreviousMD", true);
                }
                EditorPrefs.SetBool("kMonoDevelopSolutionProperties", false);

                // Support Unity Proj (JS)
                if (EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false))
                {
                    EditorPrefs.SetBool("VSCode_PreviousUnityProj", true);
                }
                EditorPrefs.SetBool("kExternalEditorSupportsUnityProj", false);

                // Attach to Editor
                if (!EditorPrefs.GetBool("AllowAttachedDebuggingOfEditor", false))
                {
                    EditorPrefs.SetBool("VSCode_PreviousAttach", false);
                }
                EditorPrefs.SetBool("AllowAttachedDebuggingOfEditor", true);
            }
            else
            {

                // Restore previous app
                if (!string.IsNullOrEmpty(EditorPrefs.GetString("VSCode_PreviousApp")))
                {
                    EditorPrefs.SetString("kScriptsDefaultApp", EditorPrefs.GetString("VSCode_PreviousApp"));
                }

                // Restore previous args
                if (!string.IsNullOrEmpty(EditorPrefs.GetString("VSCode_PreviousArgs")))
                {
                    EditorPrefs.SetString("kScriptEditorArgs", EditorPrefs.GetString("VSCode_PreviousArgs"));
                }

                // Restore MD setting
                if (EditorPrefs.GetBool("VSCode_PreviousMD", false))
                {
                    EditorPrefs.SetBool("kMonoDevelopSolutionProperties", true);
                }

                // Restore MD setting
                if (EditorPrefs.GetBool("VSCode_PreviousUnityProj", false))
                {
                    EditorPrefs.SetBool("kExternalEditorSupportsUnityProj", true);
                }


                // Restore previous attach
                if (!EditorPrefs.GetBool("VSCode_PreviousAttach", true))
                {
                    EditorPrefs.SetBool("AllowAttachedDebuggingOfEditor", false);
                }
            }

            FixUnityPreferences();
        }
示例#19
0
        /// <summary>
        /// Adds a new element to the state list which uses an existing preset.
        /// </summary>
        private void AddExistingImpactAnimatorAudioStateSetStatePreset()
        {
            var animatorAudioState = m_Shield.ImpactAnimatorAudioStateSet.States[EditorPrefs.GetInt(SelectedImpactAnimatorAudioStateSetIndexKey)];
            var states             = StateInspector.AddExistingPreset(animatorAudioState.GetType(), animatorAudioState.States, m_ReorderableImpactAnimatorAudioStateSetStateList, GetSelectedImpactAnimatorAudioStateSetStateIndexKey(EditorPrefs.GetInt(SelectedImpactAnimatorAudioStateSetIndexKey)));

            if (animatorAudioState.States.Length != states.Length)
            {
                InspectorUtility.SynchronizePropertyCount(states, m_ReorderableImpactAnimatorAudioStateSetStateList.serializedProperty);
                InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
                animatorAudioState.States = states;
            }
        }
示例#20
0
 public static bool HasAndroidSDK()
 {
     return(EditorPrefs.HasKey("AndroidSdkRoot") && System.IO.Directory.Exists(EditorPrefs.GetString("AndroidSdkRoot")));
 }
示例#21
0
        /// <summary>
        /// Returns the actions to draw before the State list is drawn.
        /// </summary>
        /// <returns>The actions to draw before the State list is drawn.</returns>
        protected override Action GetDrawCallback()
        {
            var baseCallback = base.GetDrawCallback();

            baseCallback += () =>
            {
                EditorGUILayout.PropertyField(PropertyFromName("m_RequireAim"));
                EditorGUILayout.PropertyField(PropertyFromName("m_AbsorptionFactor"));
                EditorGUILayout.PropertyField(PropertyFromName("m_AbsorbExplosions"));
                // The names will be retrieved by the Attribute Manager.
                var attributeName = InspectorUtility.DrawAttribute(m_AttributeManager, (target as Shield).DurabilityAttributeName, "Durability Attribute");
                if (attributeName != (target as Shield).DurabilityAttributeName)
                {
                    PropertyFromName("m_DurabilityAttributeName").stringValue = attributeName;
                    serializedObject.ApplyModifiedProperties();
                }
                if (!string.IsNullOrEmpty(attributeName))
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(PropertyFromName("m_DropWhenDurabilityDepleted"));
                    EditorGUI.indentLevel--;
                }

                if (Foldout("Impact"))
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(PropertyFromName("m_ApplyImpact"));
                    InspectorUtility.DrawAnimationEventTrigger(target, "Impact Complete Event", PropertyFromName("m_ImpactCompleteEvent"));
                    if (Foldout("Animator Audio"))
                    {
                        EditorGUI.indentLevel++;
                        AnimatorAudioStateSetInspector.DrawAnimatorAudioStateSet(m_Shield, m_Shield.ImpactAnimatorAudioStateSet, "m_ImpactAnimatorAudioStateSet", true,
                                                                                 ref m_ReorderableImpactAnimatorAudioStateSetList, OnImpactAnimatorAudioStateListDraw, OnImpactAnimatorAudioStateListSelect,
                                                                                 OnImpactAnimatorAudioStateListAdd, OnImpactAnimatorAudioStateListRemove, SelectedImpactAnimatorAudioStateSetIndexKey,
                                                                                 ref m_ReorderableImpactAnimatorAudioStateSetAudioList, OnImpactAudioListElementDraw, OnImpactAudioListAdd, OnImpactAudioListRemove,
                                                                                 ref m_ReorderableImpactAnimatorAudioStateSetStateList, OnImpactAnimatorAudioStateSetStateListDraw, OnImpactAnimatorAudioStateSetStateListAdd,
                                                                                 OnImpactAnimatorAudioStateSetStateListReorder, OnImpactAnimatorAudioStateListRemove,
                                                                                 GetSelectedImpactAnimatorAudioStateSetStateIndexKey(EditorPrefs.GetInt(SelectedImpactAnimatorAudioStateSetIndexKey)));
                        EditorGUI.indentLevel--;
                    }
                }

                GUI.enabled = true;
            };

            return(baseCallback);
        }
    void OnPreprocessTexture()
    {
        //return;
        var importer = (assetImporter as TextureImporter);

        UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D));
        var labels             = new List <string>(AssetDatabase.GetLabels(obj));

        if (labels == null || labels.Count == 0)
        {
            if (!String.IsNullOrEmpty(importer.userData))
            {
                labels = importer.userData.Split("," [0]).ToList();
                AssetDatabase.SetLabels(obj, labels.ToArray());
                SetLabelSetingsDirty();
            }
        }
        foreach (string label in labels)
        {
            if (Enum.IsDefined(typeof(TextureModifierType), label))
            {
                TextureModifierType type = (TextureModifierType)Enum.Parse(typeof(TextureModifierType), label);
                if (effecters.Contains(type))
                {
                    effecterType = type;
                }
                if (modifiers.Contains(type))
                {
                    modifierType = type;
                }
                if (outputs.Contains(type))
                {
                    outputType = type;
                }
            }
        }
        if (!String.IsNullOrEmpty(importer.spritePackingTag))
        {
            return;
        }
        if (effecterType != TextureModifierType.None || modifierType != TextureModifierType.None || outputType != TextureModifierType.None)
        {
            if (!EditorPrefs.GetBool(FORCESTMSETTING, true))
            {
                return;
            }
            importer.alphaIsTransparency = false;
//			importer.compressionQuality = (int)TextureCompressionQuality.Best;
            if (importer.textureFormat == TextureImporterFormat.Automatic16bit)
            {
                importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
            }
            else if (importer.textureFormat == TextureImporterFormat.AutomaticCompressed)
            {
                importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
            }
            else if (importer.textureFormat == TextureImporterFormat.RGB16)
            {
                importer.textureFormat = TextureImporterFormat.RGB24;
            }
            else if (importer.textureFormat == TextureImporterFormat.RGBA16)
            {
                importer.textureFormat = TextureImporterFormat.RGBA32;
            }
            else if (importer.textureFormat == TextureImporterFormat.ARGB16)
            {
                importer.textureFormat = TextureImporterFormat.ARGB32;
            }
        }
    }
示例#23
0
 private int GetStep()
 {
     return(EditorPrefs.GetInt("ME.ECS.QuickStart.Step", 0));
 }
    void OnPostprocessTexture(Texture2D texture)
    {
        if (effecterType == TextureModifierType.None && modifierType == TextureModifierType.None && outputType == TextureModifierType.None)
        {
            return;
        }
        AssetDatabase.StartAssetEditing();
        var pixels = texture.GetPixels();

        switch (effecterType)
        {
        case TextureModifierType.PremultipliedAlpha: {
            pixels = PremultipliedAlpha(pixels);
            break;
        }

        case TextureModifierType.AlphaBleed: {
            pixels = AlphaBleed(pixels, texture.width, texture.height);
            break;
        }
        }
        switch (modifierType)
        {
        case TextureModifierType.FloydSteinberg: {
            pixels = FloydSteinberg(pixels, texture.width, texture.height);
            break;
        }

        case TextureModifierType.Reduced16bits: {
            pixels = Reduced16bits(pixels, texture.width, texture.height);
            break;
        }
        }
        //return;
        if (EditorPrefs.GetBool(KEY, true))
        {
            switch (outputType)
            {
            case TextureModifierType.C16bits: {
                texture.SetPixels(pixels);
                texture.Apply(true, true);
                EditorUtility.CompressTexture(texture, TextureFormat.RGBA4444, TextureCompressionQuality.Best);
                break;
            }

            case TextureModifierType.CCompressed: {
                texture.SetPixels(pixels);
                texture.Apply(true, true);
                EditorUtility.CompressTexture(texture, CompressionWithAlphaFormat, TextureCompressionQuality.Best);
                break;
            }

            case TextureModifierType.CCompressedNA: {
                texture.SetPixels(pixels);
                texture.Apply(true, true);
                EditorUtility.CompressTexture(texture, CompressionFormat, TextureCompressionQuality.Best);
                break;
            }

            case TextureModifierType.CCompressedWA: {
                WriteAlphaTexture(pixels, texture);
                texture.SetPixels(pixels);
                texture.Apply(true, true);
                EditorUtility.CompressTexture(texture, CompressionFormat, TextureCompressionQuality.Best);
                break;
            }

            case TextureModifierType.TCompressed: {
                var tex = BuildTexture(texture, TextureFormat.RGBA32);
                tex.SetPixels(pixels);
                tex.Apply(true, true);
                WriteTexture(tex, CompressionWithAlphaFormat, assetPath, ".asset");
                break;
            }

            case TextureModifierType.TCompressedNA: {
                var tex = BuildTexture(texture, TextureFormat.RGBA32);
                tex.SetPixels(pixels);
                tex.Apply(true, true);
                WriteTexture(tex, CompressionFormat, assetPath, ".asset");
                break;
            }

            case TextureModifierType.TCompressedWA: {
                WriteAlphaTexture(pixels, texture);
                var tex = BuildTexture(texture, TextureFormat.RGBA32);
                tex.SetPixels(pixels);
                tex.Apply(true, true);
                WriteTexture(tex, CompressionFormat, assetPath, ".asset");
                break;
            }

            case TextureModifierType.T16bits: {
                var tex = BuildTexture(texture, TextureFormat.RGBA32);
                tex.SetPixels(pixels);
                tex.Apply(true, true);
                WriteTexture(tex, TextureFormat.RGBA4444, assetPath, ".asset");
                break;
            }

            case TextureModifierType.T32bits: {
                var tex = BuildTexture(texture, TextureFormat.RGBA32);
                tex.SetPixels(pixels);
                tex.Apply(true, true);
                WriteTexture(tex, TextureFormat.RGBA32, assetPath, ".asset");
                break;
            }

            case TextureModifierType.TPNG: {
                var tex = BuildTexture(texture, TextureFormat.RGBA32);
                tex.SetPixels(pixels);
                tex.Apply(true);
                WritePNGTexture(tex, TextureFormat.RGBA32, assetPath, "RGBA.png");
                break;
            }

            case TextureModifierType.TJPG: {
                var tex = BuildTexture(texture, TextureFormat.RGBA32);
                tex.SetPixels(pixels);
                tex.Apply(true);
                WriteJPGTexture(tex, TextureFormat.RGBA32, assetPath, "RGB.jpg");
                break;
            }

            default: {
                if (effecterType != TextureModifierType.None || modifierType != TextureModifierType.None)
                {
                    texture.SetPixels(pixels);
                    texture.Apply(true);
                }
                break;
            }
            }
        }
        AssetDatabase.Refresh();
        AssetDatabase.StopAssetEditing();
    }
示例#25
0
        /// <summary>
        /// Draws the interface for an AnimatorItemAbilitySetData.
        /// </summary>
        private static void DrawAnimatorAbilitySet(MonoBehaviour target, Dictionary <string, ReorderableList> reordableListMap, List <ReorderableList> reordableLists,
                                                   ReorderableList.SelectCallbackDelegate selectCallback, ReorderableList.AddCallbackDelegate addCallback,
                                                   ReorderableList.RemoveCallbackDelegate removeCallback, SerializedProperty abilityStatesProperty)
        {
            // The item must be attached to a RigidbodyCharacterController.
            RigidbodyCharacterController controller = null;
            var parent = target.transform.parent;

            while (parent != null)
            {
                if ((controller = parent.GetComponent <RigidbodyCharacterController>()) != null)
                {
                    break;
                }
                parent = parent.parent;
            }
            if (controller == null)
            {
                // Remove all of the ability states as they are pointing to another character.
                if (abilityStatesProperty.arraySize > 0)
                {
                    abilityStatesProperty.ClearArray();
                    abilityStatesProperty.serializedObject.ApplyModifiedProperties();
                }
                EditorGUILayout.LabelField("Please assign the item to a character.");
                return;
            }

            // Ensure the ability states are pointing to the current character. They may not be pointing to the current character if the item was switched from one
            // GameObject to another.
            if (abilityStatesProperty.arraySize > 0)
            {
                var ability = abilityStatesProperty.GetArrayElementAtIndex(0).FindPropertyRelative("m_Ability").objectReferenceValue as Ability;
                if (ability == null || ability.gameObject != controller.gameObject)
                {
                    abilityStatesProperty.ClearArray();
                    abilityStatesProperty.serializedObject.ApplyModifiedProperties();
                }
            }

            var abilitySet = new HashSet <Ability>();
            var duplicateAbilityNameSet = new HashSet <string>();
            var abilityStates           = new List <string>();
            var newAbilityStates        = new List <Ability>();

            if (abilityStatesProperty.arraySize == 0)
            {
                abilityStates.Add("(No Ability Groups)");
            }
            else
            {
                for (int i = 0; i < abilityStatesProperty.arraySize; ++i)
                {
                    var ability = abilityStatesProperty.GetArrayElementAtIndex(i).FindPropertyRelative("m_Ability").objectReferenceValue;
                    // Add the priority index if the list already contains a name with the same ability name.
                    var name = ability.GetType().Name;
                    if (duplicateAbilityNameSet.Contains(name))
                    {
                        name += string.Format("(Priority {0})", (ability as Ability).Index);
                    }
                    else
                    {
                        duplicateAbilityNameSet.Add(name);
                    }
                    abilityStates.Add(name);
                    abilitySet.Add(ability as Ability);
                }
            }

            // List any abilities that exist on the controller but have not been added to the ability list yet.
            duplicateAbilityNameSet.Clear();
            var newAbilityStartIndex = abilityStates.Count;

            for (int i = 0; i < controller.Abilities.Length; ++i)
            {
                var ability = controller.Abilities[i];
                if (abilitySet.Contains(ability))
                {
                    continue;
                }
                // Add the priority index if the list already contains a name with the same ability name.
                var name = ability.GetType().Name;
                if (duplicateAbilityNameSet.Contains(name))
                {
                    name += string.Format("(Priority {0})", (ability as Ability).Index);
                }
                else
                {
                    duplicateAbilityNameSet.Add(name);
                }
                abilityStates.Add("Add Ability Group/" + name);
                newAbilityStates.Add(ability);
            }

            // Save the selected index out to EditorPrefs to ensure the selected item stays selected across serialization reloads.
            var foldoutPath   = EditorPrefsKey + controller.gameObject + "." + abilityStatesProperty.propertyPath;
            var selectedIndex = EditorPrefs.GetInt(foldoutPath, 0);

            // Show the popup.
            EditorGUILayout.BeginHorizontal();
            selectedIndex = EditorGUILayout.Popup("Ability", selectedIndex, abilityStates.ToArray());

            // Only allow the delete button if the array contains at least one state.
            GUI.enabled = abilityStatesProperty.arraySize > 0;
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                abilityStatesProperty.DeleteArrayElementAtIndex(selectedIndex);
                abilityStatesProperty.serializedObject.ApplyModifiedProperties();
                selectedIndex = 0;
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            // Add a new ability state if the selected index is greater than the number of existing abilities.
            if (selectedIndex >= newAbilityStartIndex)
            {
                abilityStatesProperty.InsertArrayElementAtIndex(abilityStatesProperty.arraySize);
                var abilitySetProperty = abilityStatesProperty.GetArrayElementAtIndex(abilityStatesProperty.arraySize - 1);
                abilitySetProperty.FindPropertyRelative("m_Ability").objectReferenceValue = newAbilityStates[selectedIndex - newAbilityStartIndex];
                var groups = abilitySetProperty.FindPropertyRelative("m_Groups");
                // Add the default group and group state.
                if (groups.arraySize == 0)
                {
                    abilitySetProperty.FindPropertyRelative("m_Groups").InsertArrayElementAtIndex(0);
                    var group = abilitySetProperty.FindPropertyRelative("m_Groups").GetArrayElementAtIndex(0);
                    AddGroupState(group.FindPropertyRelative("m_States"));
                }
                abilityStatesProperty.serializedObject.ApplyModifiedProperties();
                selectedIndex = abilityStatesProperty.arraySize - 1;
            }
            else if (abilityStatesProperty.arraySize > 0)
            {
                // The ability isn't being added or removed. Show the selected ability set.
                DrawAnimatorSet(target, reordableListMap, reordableLists, selectCallback, addCallback, removeCallback, abilityStatesProperty.GetArrayElementAtIndex(selectedIndex), true);
            }
            EditorPrefs.SetInt(foldoutPath, selectedIndex);
        }
示例#26
0
        /// <summary>
        /// Initializzation that happens the first time the window is created
        /// </summary>
        /// <param name="materialEditor">Material editor provided by the custom inspector</param>
        /// <param name="properties">Array of materialProperties provided by the custom inspector</param>
        public void Start(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            //Temporary code for transitioning between 2017 to 2018
            if (FindProperty("_NeedsFix", properties).floatValue == 0.5)
            {
#if UNITY_2018_1_OR_NEWER
                FindProperty("_NeedsFix", properties).floatValue = 0;
#else
                FindProperty("_NeedsFix", properties).floatValue = 1;
#endif
            }


            EditorGUIUtility.labelWidth = 0f;
            //material = materialEditor.target as Material;

            //Initialize properties
            FindProperties(properties);

            //Initializes the ramp section based on the inspector level
            inspectorLevel = (InspectorLevel)EditorPrefs.GetInt("TSInspectorLevel");

            switch (inspectorLevel)
            {
            case InspectorLevel.Basic:
                basicMain = new BasicMainSection(properties);
                break;

            case InspectorLevel.Normal:
                packer = new TexturePacker(TexturePacker.Resolution.M_512x512, new string[] { "Metallic", "Smoothness", "Ambient occlusion", "Thickness map" }, GetTextureDestinationPath((Material)_RampOn.targets[0], "MSOT.png"));
                main   = new MainSection(properties, inspectorLevel, packer, this);
                break;

            case InspectorLevel.Expert:
                packer = new TexturePacker(TexturePacker.Resolution.M_512x512, new string[] { "Metallic", "Smoothness", "Ambient occlusion", "Thickness map" }, GetTextureDestinationPath((Material)_RampOn.targets[0], "MSOT.png"));
                main   = new MainSection(properties, inspectorLevel, packer, this);
                break;
            }
            foreach (Material mat in FindProperty("_Mode", properties).targets)
            {
                //remove keywords not used in Toony Standard
                RemoveUnwantedKeywords(mat);
                // Setup various keyword based settings
                SetupMaterialWithBlendMode(mat, (BlendMode)mat.GetFloat("_Mode"), mat.GetFloat("_OutlineOn") > 0);

                // Setup emission
                MaterialEditor.FixupEmissiveFlag(mat);
                bool shouldEmissionBeEnabled = (mat.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0;
                TSFunctions.SetKeyword(mat, "_EMISSION", shouldEmissionBeEnabled);
                if (shouldEmissionBeEnabled)
                {
                    mat.SetOverrideTag("IsEmissive", "true");
                }
                else
                {
                    mat.SetOverrideTag("IsEmissive", "false");
                }
            }

            GenerateRampMinMax(properties);

            // Add sections based on the inspector level
            group = new OrderedSectionGroup();
            if (inspectorLevel == InspectorLevel.Basic)
            {
                group.addSection(new BasicSpecularSection(properties, TSFunctions.BooleanFloat(_SpecularBox.floatValue), TSFunctions.BooleanFloat(_SpecularOn.floatValue)));
                group.addSection(new OutlineSection(properties, TSFunctions.BooleanFloat(_OutlineBox.floatValue), TSFunctions.BooleanFloat(_OutlineOn.floatValue)));
            }
            else
            {
                group.addSection(new RampSection(this, properties, TSFunctions.BooleanFloat(_ToonRampBox.floatValue), TSFunctions.BooleanFloat(_RampOn.floatValue)));
                group.addSection(new RimLightSection(properties, TSFunctions.BooleanFloat(_RimLightBox.floatValue), TSFunctions.BooleanFloat(_RimLightOn.floatValue)));
                group.addSection(new SpecularSection(properties, inspectorLevel, this, TSFunctions.BooleanFloat(_SpecularBox.floatValue), TSFunctions.BooleanFloat(_SpecularOn.floatValue)));
                group.addSection(new DetailSection(properties, TSFunctions.BooleanFloat(_DetailBox.floatValue), TSFunctions.BooleanFloat(_DetailMapOn.floatValue)));
                group.addSection(new SubsurfaceSection(properties, inspectorLevel, this, TSFunctions.BooleanFloat(_SSSBox.floatValue), TSFunctions.BooleanFloat(_SSSOn.floatValue)));
                group.addSection(new OutlineSection(properties, TSFunctions.BooleanFloat(_OutlineBox.floatValue), TSFunctions.BooleanFloat(_OutlineOn.floatValue)));
            }

            if (inspectorLevel == InspectorLevel.Expert)
            {
                group.addSection(new StencilSection(properties, TSFunctions.BooleanFloat(_StencilBox.floatValue), TSFunctions.BooleanFloat(_StencilOn.floatValue)));
            }
            else
            {
                FindProperty("_StencilID", properties).floatValue   = 0;
                FindProperty("_StencilComp", properties).floatValue = 0;
                FindProperty("_StencilOp", properties).floatValue   = 0;
            }
        }
示例#27
0
 /// <summary>
 /// Sets the user-preference to auto-show the demo build on success.
 /// </summary>
 /// <param name="isEnabled"></param>
 internal static void SetAutoShowBuildOnSuccessPreference(bool isEnabled)
 {
     EditorPrefs.SetBool(WearableEditorConstants.SHOW_BUILD_ON_SUCCESS_KEY, isEnabled);
 }
 public EditorVariableString(string name, string labelName, string defaultValue) : base(name, labelName, defaultValue)
 {
     m_value = EditorPrefs.GetString(name, m_defaultValue);
 }
        /// <summary>
        /// Draws all of the added states.
        /// </summary>
        private void OnUnequipAnimatorAudioStateSetStateListDraw(Rect rect, int index, bool isActive, bool isFocused)
        {
            EditorGUI.BeginChangeCheck();
            var animatorAudioState = m_Item.UnequipAnimatorAudioStateSet.States[EditorPrefs.GetInt(SelectedUnequipAnimatorAudioStateSetIndexKey)];

            // The index may be out of range if the component was copied.
            if (index >= animatorAudioState.States.Length)
            {
                m_ReorderableUnequipAnimatorAudioStateSetStateList.index = -1;
                EditorPrefs.SetInt(GetSelectedUnequipAnimatorAudioStateSetStateIndexKey(EditorPrefs.GetInt(SelectedUnequipAnimatorAudioStateSetIndexKey)), m_ReorderableUnequipAnimatorAudioStateSetStateList.index);
                return;
            }

            StateInspector.OnStateListDraw(animatorAudioState, animatorAudioState.States, rect, index);
            if (EditorGUI.EndChangeCheck())
            {
                InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
                StateInspector.UpdateDefaultStateValues(animatorAudioState.States);
            }
        }
示例#30
0
 private static void Init()
 {
     isShowSize = EditorPrefs.GetBool(FILESIZE);
     DirSizeDictionary.Clear();
     DirList.Clear();
 }