Guest User

Untitled

a guest
Mar 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. void OnGUI(){
  2. GUI.skin=myskin;
  3. GUILayout.BeginVertical ();
  4. GUILayout.Box ("sliderValue : " + Mathf.RoundToInt(sliderValue));
  5.  
  6. sliderValue = GUILayout.HorizontalSlider(sliderValue ,1.0f, maxSliderValue);
  7. if (sliderValue == 1) {
  8.  
  9.  
  10. }
  11.  
  12. }
  13.  
  14. float sliderValue;
  15. float maxSliderValue = 2.0f;
  16. public GUIStyle backgroundStyle;
  17. public GUIStyle thumbStyle;
  18. public Texture2D tex, tex2, thumbTex;
  19.  
  20. void OnGUI()
  21. {
  22. GUILayout.BeginVertical ();
  23. GUILayout.Box ("sliderValue : " + Mathf.RoundToInt(sliderValue));
  24.  
  25. thumbStyle.normal.background = thumbTex;
  26. thumbStyle.fixedWidth = 20;
  27. thumbStyle.fixedHeight = 20;
  28.  
  29. if (Mathf.RoundToInt(sliderValue) == 1)
  30. backgroundStyle.normal.background = tex;
  31. else
  32. backgroundStyle.normal.background = tex2;
  33.  
  34. sliderValue = GUILayout.HorizontalSlider(sliderValue ,1.0f, maxSliderValue, backgroundStyle, thumbStyle);
  35. }
  36.  
  37. <!DOCTYPE html>
  38. <html>
  39. <head>
  40. <meta name="viewport" content="width=device-width, initial-scale=1">
  41. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  42. <style>
  43.  
  44.  
  45.  
  46. .slidecontainer {
  47. width: 100%;
  48. }
  49.  
  50. .slider {
  51. -webkit-appearance: none;
  52. width: 100%;
  53. height: 25px;
  54. background: #d3d3d3;
  55. outline: none;
  56. opacity: 0.7;
  57. -webkit-transition: .2s;
  58. transition: opacity .2s;
  59. }
  60.  
  61. .slider {
  62. -webkit-appearance: none;
  63. width: 100%;
  64. height: 25px;
  65. background: #d3d3d3;
  66. outline: none;
  67. opacity: 0.7;
  68. -webkit-transition: .2s;
  69. transition: opacity .2s;
  70. }
  71.  
  72. .slider:hover {
  73. opacity: 1;
  74. }
  75.  
  76. .slider::-webkit-slider-thumb {
  77. -webkit-appearance: none;
  78. appearance: none;
  79. width: 75px;
  80. height: 25px;
  81. cursor: pointer;
  82. background-image:url(images/slider-bg-.jpg);
  83. background-repeat:no-repeat;
  84. }
  85.  
  86.  
  87. .slider::-moz-range-thumb {
  88. width: 75px;
  89. height: 25px;
  90. cursor: pointer;
  91. background-image:url(images/slider-bg-.jpg);
  92. background-repeat:no-repeat;
  93. }
  94.  
  95.  
  96. .valuecount::-webkit-slider-thumb {
  97. -webkit-appearance: none;
  98. appearance: none;
  99. width: 20px;
  100. height: 25px;
  101. cursor: pointer;
  102. background-image:url(images/slider-bg-.jpg);
  103. background-repeat:no-repeat;
  104. }
  105.  
  106. .valuecount::-moz-range-thumb {
  107. width: 20px;
  108. height: 25px;
  109. cursor: pointer;
  110. background-image:url(images/slider-bg-.jpg);
  111. background-repeat:no-repeat;
  112. }
  113.  
  114.  
  115.  
  116. .valuecount{
  117. height: 30px;
  118. -webkit-transition: .2s;
  119. transition: opacity .2s;
  120. overflow: hidden;
  121. clear: both;
  122. width:100%;
  123.  
  124. }
  125.  
  126. </style>
  127. </head>
  128. <body>
  129. <h1>Custom Range Slider</h1>
  130. <p>Drag the slider to display the current value.</p>
  131.  
  132. <div class="slidecontainer">
  133. <input type="range" list="tickmarks" class="valuecount">
  134. <datalist id="tickmarks">
  135. <option value="0" label="0%">
  136. <option value="10">
  137. <option value="20">
  138. <option value="30">
  139. <option value="40">
  140. <option value="50" label="50%">
  141. <option value="60">
  142. <option value="70">
  143. <option value="80">
  144. <option value="90">
  145. <option value="100" label="100%">
  146. </datalist>
  147. </div>
  148. <script>
  149. var slider = document.getElementById("myRange");
  150. var output = document.getElementById("demo");
  151. output.innerHTML = slider.value;
  152.  
  153. slider.oninput = function() {
  154. output.innerHTML = this.value;
  155. }
  156. </script>
  157. </body>
  158. </html>
Add Comment
Please, Sign In to add comment